From 18a8f486023ff7a4a86451bddc80d1a26a512ccf Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 25 Sep 2023 16:39:03 +0000 Subject: [PATCH 1/2] feat: add optional SpeechConfig to UploadConversationRequest 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= --- .../v1/.coveragerc | 13 + .../v1/.flake8 | 33 + .../v1/MANIFEST.in | 2 + .../v1/README.rst | 49 + .../v1/docs/_static/custom.css | 3 + .../v1/docs/conf.py | 376 + .../contact_center_insights.rst | 10 + .../contact_center_insights_v1/services.rst | 6 + .../docs/contact_center_insights_v1/types.rst | 6 + .../v1/docs/index.rst | 7 + .../cloud/contact_center_insights/__init__.py | 237 + .../contact_center_insights/gapic_version.py | 16 + .../cloud/contact_center_insights/py.typed | 2 + .../contact_center_insights_v1/__init__.py | 238 + .../gapic_metadata.json | 598 + .../gapic_version.py | 16 + .../cloud/contact_center_insights_v1/py.typed | 2 + .../services/__init__.py | 15 + .../contact_center_insights/__init__.py | 22 + .../contact_center_insights/async_client.py | 4421 ++++ .../contact_center_insights/client.py | 4707 ++++ .../contact_center_insights/pagers.py | 503 + .../transports/__init__.py | 38 + .../transports/base.py | 702 + .../transports/grpc.py | 1311 + .../transports/grpc_asyncio.py | 1310 + .../transports/rest.py | 4718 ++++ .../types/__init__.py | 232 + .../types/contact_center_insights.py | 1838 ++ .../types/resources.py | 2539 ++ .../v1/mypy.ini | 3 + .../v1/noxfile.py | 184 + ...sights_bulk_analyze_conversations_async.py | 58 + ...nsights_bulk_analyze_conversations_sync.py | 58 + ...ights_calculate_issue_model_stats_async.py | 52 + ...sights_calculate_issue_model_stats_sync.py | 52 + ...t_center_insights_calculate_stats_async.py | 52 + ...ct_center_insights_calculate_stats_sync.py | 52 + ...t_center_insights_create_analysis_async.py | 56 + ...ct_center_insights_create_analysis_sync.py | 56 + ...nter_insights_create_conversation_async.py | 52 + ...enter_insights_create_conversation_sync.py | 52 + ...enter_insights_create_issue_model_async.py | 56 + ...center_insights_create_issue_model_sync.py | 56 + ...er_insights_create_phrase_matcher_async.py | 56 + ...ter_insights_create_phrase_matcher_sync.py | 56 + ...ntact_center_insights_create_view_async.py | 52 + ...ontact_center_insights_create_view_sync.py | 52 + ...t_center_insights_delete_analysis_async.py | 50 + ...ct_center_insights_delete_analysis_sync.py | 50 + ...nter_insights_delete_conversation_async.py | 50 + ...enter_insights_delete_conversation_sync.py | 50 + ...tact_center_insights_delete_issue_async.py | 50 + ...enter_insights_delete_issue_model_async.py | 56 + ...center_insights_delete_issue_model_sync.py | 56 + ...ntact_center_insights_delete_issue_sync.py | 50 + ...er_insights_delete_phrase_matcher_async.py | 50 + ...ter_insights_delete_phrase_matcher_sync.py | 50 + ...ntact_center_insights_delete_view_async.py | 50 + ...ontact_center_insights_delete_view_sync.py | 50 + ...enter_insights_deploy_issue_model_async.py | 56 + ...center_insights_deploy_issue_model_sync.py | 56 + ...ter_insights_export_insights_data_async.py | 60 + ...nter_insights_export_insights_data_sync.py | 60 + ...tact_center_insights_get_analysis_async.py | 52 + ...ntact_center_insights_get_analysis_sync.py | 52 + ..._center_insights_get_conversation_async.py | 52 + ...t_center_insights_get_conversation_sync.py | 52 + ...contact_center_insights_get_issue_async.py | 52 + ...t_center_insights_get_issue_model_async.py | 52 + ...ct_center_insights_get_issue_model_sync.py | 52 + ..._contact_center_insights_get_issue_sync.py | 52 + ...enter_insights_get_phrase_matcher_async.py | 52 + ...center_insights_get_phrase_matcher_sync.py | 52 + ...tact_center_insights_get_settings_async.py | 52 + ...ntact_center_insights_get_settings_sync.py | 52 + ..._contact_center_insights_get_view_async.py | 52 + ...d_contact_center_insights_get_view_sync.py | 52 + ...ter_insights_ingest_conversations_async.py | 64 + ...nter_insights_ingest_conversations_sync.py | 64 + ...act_center_insights_list_analyses_async.py | 53 + ...tact_center_insights_list_analyses_sync.py | 53 + ...enter_insights_list_conversations_async.py | 53 + ...center_insights_list_conversations_sync.py | 53 + ...center_insights_list_issue_models_async.py | 52 + ..._center_insights_list_issue_models_sync.py | 52 + ...ntact_center_insights_list_issues_async.py | 52 + ...ontact_center_insights_list_issues_sync.py | 52 + ...ter_insights_list_phrase_matchers_async.py | 53 + ...nter_insights_list_phrase_matchers_sync.py | 53 + ...ontact_center_insights_list_views_async.py | 53 + ...contact_center_insights_list_views_sync.py | 53 + ...ter_insights_undeploy_issue_model_async.py | 56 + ...nter_insights_undeploy_issue_model_sync.py | 56 + ...nter_insights_update_conversation_async.py | 51 + ...enter_insights_update_conversation_sync.py | 51 + ...tact_center_insights_update_issue_async.py | 51 + ...enter_insights_update_issue_model_async.py | 51 + ...center_insights_update_issue_model_sync.py | 51 + ...ntact_center_insights_update_issue_sync.py | 51 + ...er_insights_update_phrase_matcher_async.py | 55 + ...ter_insights_update_phrase_matcher_sync.py | 55 + ...t_center_insights_update_settings_async.py | 51 + ...ct_center_insights_update_settings_sync.py | 51 + ...ntact_center_insights_update_view_async.py | 51 + ...ontact_center_insights_update_view_sync.py | 51 + ...nter_insights_upload_conversation_async.py | 56 + ...enter_insights_upload_conversation_sync.py | 56 + ...google.cloud.contactcenterinsights.v1.json | 6207 +++++ ...xup_contact_center_insights_v1_keywords.py | 213 + .../v1/setup.py | 90 + .../v1/testing/constraints-3.10.txt | 6 + .../v1/testing/constraints-3.11.txt | 6 + .../v1/testing/constraints-3.12.txt | 6 + .../v1/testing/constraints-3.7.txt | 9 + .../v1/testing/constraints-3.8.txt | 6 + .../v1/testing/constraints-3.9.txt | 6 + .../v1/tests/__init__.py | 16 + .../v1/tests/unit/__init__.py | 16 + .../v1/tests/unit/gapic/__init__.py | 16 + .../contact_center_insights_v1/__init__.py | 16 + .../test_contact_center_insights.py | 21043 ++++++++++++++++ 122 files changed, 55857 insertions(+) create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/.coveragerc create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/.flake8 create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/MANIFEST.in create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/README.rst create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/docs/_static/custom.css create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/docs/conf.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/contact_center_insights.rst create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/services.rst create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/types.rst create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/docs/index.rst create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/__init__.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/gapic_version.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/py.typed create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/__init__.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/gapic_version.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/py.typed create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/__init__.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/__init__.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/pagers.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/__init__.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/rest.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/__init__.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/contact_center_insights.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/resources.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/mypy.ini create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/noxfile.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_conversation_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_conversation_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_view_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_view_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_view_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_view_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_conversation_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_conversation_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_settings_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_settings_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_view_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_view_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analyses_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analyses_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_conversations_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_conversations_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issues_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issues_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_views_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_views_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_conversation_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_conversation_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_settings_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_settings_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_view_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_view_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_async.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_sync.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/snippet_metadata_google.cloud.contactcenterinsights.v1.json create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/scripts/fixup_contact_center_insights_v1_keywords.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/setup.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.10.txt create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.11.txt create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.12.txt create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.7.txt create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.8.txt create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.9.txt create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/tests/__init__.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/__init__.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/__init__.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/contact_center_insights_v1/__init__.py create mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/.coveragerc b/owl-bot-staging/google-cloud-contact-center-insights/v1/.coveragerc new file mode 100644 index 000000000000..790480a7ffe3 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/.coveragerc @@ -0,0 +1,13 @@ +[run] +branch = True + +[report] +show_missing = True +omit = + google/cloud/contact_center_insights/__init__.py + google/cloud/contact_center_insights/gapic_version.py +exclude_lines = + # Re-enable the standard pragma + pragma: NO COVER + # Ignore debug-only repr + def __repr__ diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/.flake8 b/owl-bot-staging/google-cloud-contact-center-insights/v1/.flake8 new file mode 100644 index 000000000000..29227d4cf419 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/.flake8 @@ -0,0 +1,33 @@ +# -*- 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 +# +# https://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. + +# Generated by synthtool. DO NOT EDIT! +[flake8] +ignore = E203, E266, E501, W503 +exclude = + # Exclude generated code. + **/proto/** + **/gapic/** + **/services/** + **/types/** + *_pb2.py + + # Standard linting exemptions. + **/.nox/** + __pycache__, + .git, + *.pyc, + conf.py diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/MANIFEST.in b/owl-bot-staging/google-cloud-contact-center-insights/v1/MANIFEST.in new file mode 100644 index 000000000000..405104e9d5c6 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include google/cloud/contact_center_insights *.py +recursive-include google/cloud/contact_center_insights_v1 *.py diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/README.rst b/owl-bot-staging/google-cloud-contact-center-insights/v1/README.rst new file mode 100644 index 000000000000..d53e8514665f --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/README.rst @@ -0,0 +1,49 @@ +Python Client for Google Cloud Contact Center Insights API +================================================= + +Quick Start +----------- + +In order to use this library, you first need to go through the following steps: + +1. `Select or create a Cloud Platform project.`_ +2. `Enable billing for your project.`_ +3. Enable the Google Cloud Contact Center Insights API. +4. `Setup Authentication.`_ + +.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project +.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project +.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html + +Installation +~~~~~~~~~~~~ + +Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to +create isolated Python environments. The basic problem it addresses is one of +dependencies and versions, and indirectly permissions. + +With `virtualenv`_, it's possible to install this library without needing system +install permissions, and without clashing with the installed system +dependencies. + +.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ + + +Mac/Linux +^^^^^^^^^ + +.. code-block:: console + + python3 -m venv + source /bin/activate + /bin/pip install /path/to/library + + +Windows +^^^^^^^ + +.. code-block:: console + + python3 -m venv + \Scripts\activate + \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/_static/custom.css b/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/_static/custom.css new file mode 100644 index 000000000000..06423be0b592 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/_static/custom.css @@ -0,0 +1,3 @@ +dl.field-list > dt { + min-width: 100px +} diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/conf.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/conf.py new file mode 100644 index 000000000000..a1dbf8f2d907 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/conf.py @@ -0,0 +1,376 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# +# google-cloud-contact-center-insights documentation build configuration file +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import shlex + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath("..")) + +__version__ = "0.1.0" + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +needs_sphinx = "4.0.1" + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.intersphinx", + "sphinx.ext.coverage", + "sphinx.ext.napoleon", + "sphinx.ext.todo", + "sphinx.ext.viewcode", +] + +# autodoc/autosummary flags +autoclass_content = "both" +autodoc_default_flags = ["members"] +autosummary_generate = True + + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# Allow markdown includes (so releases.md can include CHANGLEOG.md) +# http://www.sphinx-doc.org/en/master/markdown.html +source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +source_suffix = [".rst", ".md"] + +# The encoding of source files. +# source_encoding = 'utf-8-sig' + +# The root toctree document. +root_doc = "index" + +# General information about the project. +project = u"google-cloud-contact-center-insights" +copyright = u"2023, Google, LLC" +author = u"Google APIs" # TODO: autogenerate this bit + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The full version, including alpha/beta/rc tags. +release = __version__ +# The short X.Y version. +version = ".".join(release.split(".")[0:2]) + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = 'en' + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ["_build"] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = "sphinx" + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = "alabaster" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +html_theme_options = { + "description": "Google Cloud Client Libraries for Python", + "github_user": "googleapis", + "github_repo": "google-cloud-python", + "github_banner": True, + "font_family": "'Roboto', Georgia, sans", + "head_font_family": "'Roboto', Georgia, serif", + "code_font_family": "'Roboto Mono', 'Consolas', monospace", +} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +# html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +# html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# html_additional_pages = {} + +# If false, no module index is generated. +# html_domain_indices = True + +# If false, no index is generated. +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' +# html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# Now only 'ja' uses this config value +# html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +# html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = "google-cloud-contact-center-insights-doc" + +# -- Options for warnings ------------------------------------------------------ + + +suppress_warnings = [ + # Temporarily suppress this to avoid "more than one target found for + # cross-reference" warning, which are intractable for us to avoid while in + # a mono-repo. + # See https://github.com/sphinx-doc/sphinx/blob + # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 + "ref.python" +] + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # 'preamble': '', + # Latex figure (float) alignment + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ( + root_doc, + "google-cloud-contact-center-insights.tex", + u"google-cloud-contact-center-insights Documentation", + author, + "manual", + ) +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# latex_use_parts = False + +# If true, show page references after internal links. +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# latex_appendices = [] + +# If false, no module index is generated. +# latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ( + root_doc, + "google-cloud-contact-center-insights", + u"Google Cloud Contact Center Insights Documentation", + [author], + 1, + ) +] + +# If true, show URL addresses after external links. +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ( + root_doc, + "google-cloud-contact-center-insights", + u"google-cloud-contact-center-insights Documentation", + author, + "google-cloud-contact-center-insights", + "GAPIC library for Google Cloud Contact Center Insights API", + "APIs", + ) +] + +# Documents to append as an appendix to all manuals. +# texinfo_appendices = [] + +# If false, no module index is generated. +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +# texinfo_no_detailmenu = False + + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = { + "python": ("http://python.readthedocs.org/en/latest/", None), + "gax": ("https://gax-python.readthedocs.org/en/latest/", None), + "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), + "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), + "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), + "grpc": ("https://grpc.io/grpc/python/", None), + "requests": ("http://requests.kennethreitz.org/en/stable/", None), + "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), + "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), +} + + +# Napoleon settings +napoleon_google_docstring = True +napoleon_numpy_docstring = True +napoleon_include_private_with_doc = False +napoleon_include_special_with_doc = True +napoleon_use_admonition_for_examples = False +napoleon_use_admonition_for_notes = False +napoleon_use_admonition_for_references = False +napoleon_use_ivar = False +napoleon_use_param = True +napoleon_use_rtype = True diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/contact_center_insights.rst b/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/contact_center_insights.rst new file mode 100644 index 000000000000..bb343f0b0f34 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/contact_center_insights.rst @@ -0,0 +1,10 @@ +ContactCenterInsights +--------------------------------------- + +.. automodule:: google.cloud.contact_center_insights_v1.services.contact_center_insights + :members: + :inherited-members: + +.. automodule:: google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/services.rst b/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/services.rst new file mode 100644 index 000000000000..0147aecd0488 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/services.rst @@ -0,0 +1,6 @@ +Services for Google Cloud Contact Center Insights v1 API +======================================================== +.. toctree:: + :maxdepth: 2 + + contact_center_insights diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/types.rst b/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/types.rst new file mode 100644 index 000000000000..270019e6a6fe --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/types.rst @@ -0,0 +1,6 @@ +Types for Google Cloud Contact Center Insights v1 API +===================================================== + +.. automodule:: google.cloud.contact_center_insights_v1.types + :members: + :show-inheritance: diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/index.rst b/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/index.rst new file mode 100644 index 000000000000..d91ad872f07d --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/index.rst @@ -0,0 +1,7 @@ +API Reference +------------- +.. toctree:: + :maxdepth: 2 + + contact_center_insights_v1/services + contact_center_insights_v1/types diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/__init__.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/__init__.py new file mode 100644 index 000000000000..02503043743d --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/__init__.py @@ -0,0 +1,237 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +from google.cloud.contact_center_insights import gapic_version as package_version + +__version__ = package_version.__version__ + + +from google.cloud.contact_center_insights_v1.services.contact_center_insights.client import ContactCenterInsightsClient +from google.cloud.contact_center_insights_v1.services.contact_center_insights.async_client import ContactCenterInsightsAsyncClient + +from google.cloud.contact_center_insights_v1.types.contact_center_insights import BulkAnalyzeConversationsMetadata +from google.cloud.contact_center_insights_v1.types.contact_center_insights import BulkAnalyzeConversationsRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import BulkAnalyzeConversationsResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CalculateIssueModelStatsRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CalculateIssueModelStatsResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CalculateStatsRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CalculateStatsResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CreateAnalysisOperationMetadata +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CreateAnalysisRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CreateConversationRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CreateIssueModelMetadata +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CreateIssueModelRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CreatePhraseMatcherRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import CreateViewRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeleteAnalysisRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeleteConversationRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeleteIssueModelMetadata +from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeleteIssueModelRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeleteIssueRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeletePhraseMatcherRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeleteViewRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeployIssueModelMetadata +from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeployIssueModelRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeployIssueModelResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ExportInsightsDataMetadata +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ExportInsightsDataRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ExportInsightsDataResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import GetAnalysisRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import GetConversationRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import GetIssueModelRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import GetIssueRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import GetPhraseMatcherRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import GetSettingsRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import GetViewRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import IngestConversationsMetadata +from google.cloud.contact_center_insights_v1.types.contact_center_insights import IngestConversationsRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import IngestConversationsResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListAnalysesRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListAnalysesResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListConversationsRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListConversationsResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListIssueModelsRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListIssueModelsResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListIssuesRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListIssuesResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListPhraseMatchersRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListPhraseMatchersResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListViewsRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListViewsResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import UndeployIssueModelMetadata +from google.cloud.contact_center_insights_v1.types.contact_center_insights import UndeployIssueModelRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import UndeployIssueModelResponse +from google.cloud.contact_center_insights_v1.types.contact_center_insights import UpdateConversationRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import UpdateIssueModelRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import UpdateIssueRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import UpdatePhraseMatcherRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import UpdateSettingsRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import UpdateViewRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import UploadConversationMetadata +from google.cloud.contact_center_insights_v1.types.contact_center_insights import UploadConversationRequest +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ConversationView +from google.cloud.contact_center_insights_v1.types.resources import Analysis +from google.cloud.contact_center_insights_v1.types.resources import AnalysisResult +from google.cloud.contact_center_insights_v1.types.resources import AnnotationBoundary +from google.cloud.contact_center_insights_v1.types.resources import AnnotatorSelector +from google.cloud.contact_center_insights_v1.types.resources import AnswerFeedback +from google.cloud.contact_center_insights_v1.types.resources import ArticleSuggestionData +from google.cloud.contact_center_insights_v1.types.resources import CallAnnotation +from google.cloud.contact_center_insights_v1.types.resources import Conversation +from google.cloud.contact_center_insights_v1.types.resources import ConversationDataSource +from google.cloud.contact_center_insights_v1.types.resources import ConversationLevelSentiment +from google.cloud.contact_center_insights_v1.types.resources import ConversationParticipant +from google.cloud.contact_center_insights_v1.types.resources import ConversationSummarizationSuggestionData +from google.cloud.contact_center_insights_v1.types.resources import DialogflowIntent +from google.cloud.contact_center_insights_v1.types.resources import DialogflowInteractionData +from google.cloud.contact_center_insights_v1.types.resources import DialogflowSource +from google.cloud.contact_center_insights_v1.types.resources import Entity +from google.cloud.contact_center_insights_v1.types.resources import EntityMentionData +from google.cloud.contact_center_insights_v1.types.resources import ExactMatchConfig +from google.cloud.contact_center_insights_v1.types.resources import FaqAnswerData +from google.cloud.contact_center_insights_v1.types.resources import GcsSource +from google.cloud.contact_center_insights_v1.types.resources import HoldData +from google.cloud.contact_center_insights_v1.types.resources import Intent +from google.cloud.contact_center_insights_v1.types.resources import IntentMatchData +from google.cloud.contact_center_insights_v1.types.resources import InterruptionData +from google.cloud.contact_center_insights_v1.types.resources import Issue +from google.cloud.contact_center_insights_v1.types.resources import IssueAssignment +from google.cloud.contact_center_insights_v1.types.resources import IssueMatchData +from google.cloud.contact_center_insights_v1.types.resources import IssueModel +from google.cloud.contact_center_insights_v1.types.resources import IssueModelLabelStats +from google.cloud.contact_center_insights_v1.types.resources import IssueModelResult +from google.cloud.contact_center_insights_v1.types.resources import PhraseMatchData +from google.cloud.contact_center_insights_v1.types.resources import PhraseMatcher +from google.cloud.contact_center_insights_v1.types.resources import PhraseMatchRule +from google.cloud.contact_center_insights_v1.types.resources import PhraseMatchRuleConfig +from google.cloud.contact_center_insights_v1.types.resources import PhraseMatchRuleGroup +from google.cloud.contact_center_insights_v1.types.resources import RedactionConfig +from google.cloud.contact_center_insights_v1.types.resources import RuntimeAnnotation +from google.cloud.contact_center_insights_v1.types.resources import SentimentData +from google.cloud.contact_center_insights_v1.types.resources import Settings +from google.cloud.contact_center_insights_v1.types.resources import SilenceData +from google.cloud.contact_center_insights_v1.types.resources import SmartComposeSuggestionData +from google.cloud.contact_center_insights_v1.types.resources import SmartReplyData +from google.cloud.contact_center_insights_v1.types.resources import SpeechConfig +from google.cloud.contact_center_insights_v1.types.resources import View + +__all__ = ('ContactCenterInsightsClient', + 'ContactCenterInsightsAsyncClient', + 'BulkAnalyzeConversationsMetadata', + 'BulkAnalyzeConversationsRequest', + 'BulkAnalyzeConversationsResponse', + 'CalculateIssueModelStatsRequest', + 'CalculateIssueModelStatsResponse', + 'CalculateStatsRequest', + 'CalculateStatsResponse', + 'CreateAnalysisOperationMetadata', + 'CreateAnalysisRequest', + 'CreateConversationRequest', + 'CreateIssueModelMetadata', + 'CreateIssueModelRequest', + 'CreatePhraseMatcherRequest', + 'CreateViewRequest', + 'DeleteAnalysisRequest', + 'DeleteConversationRequest', + 'DeleteIssueModelMetadata', + 'DeleteIssueModelRequest', + 'DeleteIssueRequest', + 'DeletePhraseMatcherRequest', + 'DeleteViewRequest', + 'DeployIssueModelMetadata', + 'DeployIssueModelRequest', + 'DeployIssueModelResponse', + 'ExportInsightsDataMetadata', + 'ExportInsightsDataRequest', + 'ExportInsightsDataResponse', + 'GetAnalysisRequest', + 'GetConversationRequest', + 'GetIssueModelRequest', + 'GetIssueRequest', + 'GetPhraseMatcherRequest', + 'GetSettingsRequest', + 'GetViewRequest', + 'IngestConversationsMetadata', + 'IngestConversationsRequest', + 'IngestConversationsResponse', + 'ListAnalysesRequest', + 'ListAnalysesResponse', + 'ListConversationsRequest', + 'ListConversationsResponse', + 'ListIssueModelsRequest', + 'ListIssueModelsResponse', + 'ListIssuesRequest', + 'ListIssuesResponse', + 'ListPhraseMatchersRequest', + 'ListPhraseMatchersResponse', + 'ListViewsRequest', + 'ListViewsResponse', + 'UndeployIssueModelMetadata', + 'UndeployIssueModelRequest', + 'UndeployIssueModelResponse', + 'UpdateConversationRequest', + 'UpdateIssueModelRequest', + 'UpdateIssueRequest', + 'UpdatePhraseMatcherRequest', + 'UpdateSettingsRequest', + 'UpdateViewRequest', + 'UploadConversationMetadata', + 'UploadConversationRequest', + 'ConversationView', + 'Analysis', + 'AnalysisResult', + 'AnnotationBoundary', + 'AnnotatorSelector', + 'AnswerFeedback', + 'ArticleSuggestionData', + 'CallAnnotation', + 'Conversation', + 'ConversationDataSource', + 'ConversationLevelSentiment', + 'ConversationParticipant', + 'ConversationSummarizationSuggestionData', + 'DialogflowIntent', + 'DialogflowInteractionData', + 'DialogflowSource', + 'Entity', + 'EntityMentionData', + 'ExactMatchConfig', + 'FaqAnswerData', + 'GcsSource', + 'HoldData', + 'Intent', + 'IntentMatchData', + 'InterruptionData', + 'Issue', + 'IssueAssignment', + 'IssueMatchData', + 'IssueModel', + 'IssueModelLabelStats', + 'IssueModelResult', + 'PhraseMatchData', + 'PhraseMatcher', + 'PhraseMatchRule', + 'PhraseMatchRuleConfig', + 'PhraseMatchRuleGroup', + 'RedactionConfig', + 'RuntimeAnnotation', + 'SentimentData', + 'Settings', + 'SilenceData', + 'SmartComposeSuggestionData', + 'SmartReplyData', + 'SpeechConfig', + 'View', +) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/gapic_version.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/gapic_version.py new file mode 100644 index 000000000000..360a0d13ebdd --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/gapic_version.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +__version__ = "0.0.0" # {x-release-please-version} diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/py.typed b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/py.typed new file mode 100644 index 000000000000..d02b3b435cbb --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-contact-center-insights package uses inline types. diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/__init__.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/__init__.py new file mode 100644 index 000000000000..fd1cbb00e141 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/__init__.py @@ -0,0 +1,238 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +from google.cloud.contact_center_insights_v1 import gapic_version as package_version + +__version__ = package_version.__version__ + + +from .services.contact_center_insights import ContactCenterInsightsClient +from .services.contact_center_insights import ContactCenterInsightsAsyncClient + +from .types.contact_center_insights import BulkAnalyzeConversationsMetadata +from .types.contact_center_insights import BulkAnalyzeConversationsRequest +from .types.contact_center_insights import BulkAnalyzeConversationsResponse +from .types.contact_center_insights import CalculateIssueModelStatsRequest +from .types.contact_center_insights import CalculateIssueModelStatsResponse +from .types.contact_center_insights import CalculateStatsRequest +from .types.contact_center_insights import CalculateStatsResponse +from .types.contact_center_insights import CreateAnalysisOperationMetadata +from .types.contact_center_insights import CreateAnalysisRequest +from .types.contact_center_insights import CreateConversationRequest +from .types.contact_center_insights import CreateIssueModelMetadata +from .types.contact_center_insights import CreateIssueModelRequest +from .types.contact_center_insights import CreatePhraseMatcherRequest +from .types.contact_center_insights import CreateViewRequest +from .types.contact_center_insights import DeleteAnalysisRequest +from .types.contact_center_insights import DeleteConversationRequest +from .types.contact_center_insights import DeleteIssueModelMetadata +from .types.contact_center_insights import DeleteIssueModelRequest +from .types.contact_center_insights import DeleteIssueRequest +from .types.contact_center_insights import DeletePhraseMatcherRequest +from .types.contact_center_insights import DeleteViewRequest +from .types.contact_center_insights import DeployIssueModelMetadata +from .types.contact_center_insights import DeployIssueModelRequest +from .types.contact_center_insights import DeployIssueModelResponse +from .types.contact_center_insights import ExportInsightsDataMetadata +from .types.contact_center_insights import ExportInsightsDataRequest +from .types.contact_center_insights import ExportInsightsDataResponse +from .types.contact_center_insights import GetAnalysisRequest +from .types.contact_center_insights import GetConversationRequest +from .types.contact_center_insights import GetIssueModelRequest +from .types.contact_center_insights import GetIssueRequest +from .types.contact_center_insights import GetPhraseMatcherRequest +from .types.contact_center_insights import GetSettingsRequest +from .types.contact_center_insights import GetViewRequest +from .types.contact_center_insights import IngestConversationsMetadata +from .types.contact_center_insights import IngestConversationsRequest +from .types.contact_center_insights import IngestConversationsResponse +from .types.contact_center_insights import ListAnalysesRequest +from .types.contact_center_insights import ListAnalysesResponse +from .types.contact_center_insights import ListConversationsRequest +from .types.contact_center_insights import ListConversationsResponse +from .types.contact_center_insights import ListIssueModelsRequest +from .types.contact_center_insights import ListIssueModelsResponse +from .types.contact_center_insights import ListIssuesRequest +from .types.contact_center_insights import ListIssuesResponse +from .types.contact_center_insights import ListPhraseMatchersRequest +from .types.contact_center_insights import ListPhraseMatchersResponse +from .types.contact_center_insights import ListViewsRequest +from .types.contact_center_insights import ListViewsResponse +from .types.contact_center_insights import UndeployIssueModelMetadata +from .types.contact_center_insights import UndeployIssueModelRequest +from .types.contact_center_insights import UndeployIssueModelResponse +from .types.contact_center_insights import UpdateConversationRequest +from .types.contact_center_insights import UpdateIssueModelRequest +from .types.contact_center_insights import UpdateIssueRequest +from .types.contact_center_insights import UpdatePhraseMatcherRequest +from .types.contact_center_insights import UpdateSettingsRequest +from .types.contact_center_insights import UpdateViewRequest +from .types.contact_center_insights import UploadConversationMetadata +from .types.contact_center_insights import UploadConversationRequest +from .types.contact_center_insights import ConversationView +from .types.resources import Analysis +from .types.resources import AnalysisResult +from .types.resources import AnnotationBoundary +from .types.resources import AnnotatorSelector +from .types.resources import AnswerFeedback +from .types.resources import ArticleSuggestionData +from .types.resources import CallAnnotation +from .types.resources import Conversation +from .types.resources import ConversationDataSource +from .types.resources import ConversationLevelSentiment +from .types.resources import ConversationParticipant +from .types.resources import ConversationSummarizationSuggestionData +from .types.resources import DialogflowIntent +from .types.resources import DialogflowInteractionData +from .types.resources import DialogflowSource +from .types.resources import Entity +from .types.resources import EntityMentionData +from .types.resources import ExactMatchConfig +from .types.resources import FaqAnswerData +from .types.resources import GcsSource +from .types.resources import HoldData +from .types.resources import Intent +from .types.resources import IntentMatchData +from .types.resources import InterruptionData +from .types.resources import Issue +from .types.resources import IssueAssignment +from .types.resources import IssueMatchData +from .types.resources import IssueModel +from .types.resources import IssueModelLabelStats +from .types.resources import IssueModelResult +from .types.resources import PhraseMatchData +from .types.resources import PhraseMatcher +from .types.resources import PhraseMatchRule +from .types.resources import PhraseMatchRuleConfig +from .types.resources import PhraseMatchRuleGroup +from .types.resources import RedactionConfig +from .types.resources import RuntimeAnnotation +from .types.resources import SentimentData +from .types.resources import Settings +from .types.resources import SilenceData +from .types.resources import SmartComposeSuggestionData +from .types.resources import SmartReplyData +from .types.resources import SpeechConfig +from .types.resources import View + +__all__ = ( + 'ContactCenterInsightsAsyncClient', +'Analysis', +'AnalysisResult', +'AnnotationBoundary', +'AnnotatorSelector', +'AnswerFeedback', +'ArticleSuggestionData', +'BulkAnalyzeConversationsMetadata', +'BulkAnalyzeConversationsRequest', +'BulkAnalyzeConversationsResponse', +'CalculateIssueModelStatsRequest', +'CalculateIssueModelStatsResponse', +'CalculateStatsRequest', +'CalculateStatsResponse', +'CallAnnotation', +'ContactCenterInsightsClient', +'Conversation', +'ConversationDataSource', +'ConversationLevelSentiment', +'ConversationParticipant', +'ConversationSummarizationSuggestionData', +'ConversationView', +'CreateAnalysisOperationMetadata', +'CreateAnalysisRequest', +'CreateConversationRequest', +'CreateIssueModelMetadata', +'CreateIssueModelRequest', +'CreatePhraseMatcherRequest', +'CreateViewRequest', +'DeleteAnalysisRequest', +'DeleteConversationRequest', +'DeleteIssueModelMetadata', +'DeleteIssueModelRequest', +'DeleteIssueRequest', +'DeletePhraseMatcherRequest', +'DeleteViewRequest', +'DeployIssueModelMetadata', +'DeployIssueModelRequest', +'DeployIssueModelResponse', +'DialogflowIntent', +'DialogflowInteractionData', +'DialogflowSource', +'Entity', +'EntityMentionData', +'ExactMatchConfig', +'ExportInsightsDataMetadata', +'ExportInsightsDataRequest', +'ExportInsightsDataResponse', +'FaqAnswerData', +'GcsSource', +'GetAnalysisRequest', +'GetConversationRequest', +'GetIssueModelRequest', +'GetIssueRequest', +'GetPhraseMatcherRequest', +'GetSettingsRequest', +'GetViewRequest', +'HoldData', +'IngestConversationsMetadata', +'IngestConversationsRequest', +'IngestConversationsResponse', +'Intent', +'IntentMatchData', +'InterruptionData', +'Issue', +'IssueAssignment', +'IssueMatchData', +'IssueModel', +'IssueModelLabelStats', +'IssueModelResult', +'ListAnalysesRequest', +'ListAnalysesResponse', +'ListConversationsRequest', +'ListConversationsResponse', +'ListIssueModelsRequest', +'ListIssueModelsResponse', +'ListIssuesRequest', +'ListIssuesResponse', +'ListPhraseMatchersRequest', +'ListPhraseMatchersResponse', +'ListViewsRequest', +'ListViewsResponse', +'PhraseMatchData', +'PhraseMatchRule', +'PhraseMatchRuleConfig', +'PhraseMatchRuleGroup', +'PhraseMatcher', +'RedactionConfig', +'RuntimeAnnotation', +'SentimentData', +'Settings', +'SilenceData', +'SmartComposeSuggestionData', +'SmartReplyData', +'SpeechConfig', +'UndeployIssueModelMetadata', +'UndeployIssueModelRequest', +'UndeployIssueModelResponse', +'UpdateConversationRequest', +'UpdateIssueModelRequest', +'UpdateIssueRequest', +'UpdatePhraseMatcherRequest', +'UpdateSettingsRequest', +'UpdateViewRequest', +'UploadConversationMetadata', +'UploadConversationRequest', +'View', +) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/gapic_metadata.json b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/gapic_metadata.json new file mode 100644 index 000000000000..bc4e05861648 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/gapic_metadata.json @@ -0,0 +1,598 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.contact_center_insights_v1", + "protoPackage": "google.cloud.contactcenterinsights.v1", + "schema": "1.0", + "services": { + "ContactCenterInsights": { + "clients": { + "grpc": { + "libraryClient": "ContactCenterInsightsClient", + "rpcs": { + "BulkAnalyzeConversations": { + "methods": [ + "bulk_analyze_conversations" + ] + }, + "CalculateIssueModelStats": { + "methods": [ + "calculate_issue_model_stats" + ] + }, + "CalculateStats": { + "methods": [ + "calculate_stats" + ] + }, + "CreateAnalysis": { + "methods": [ + "create_analysis" + ] + }, + "CreateConversation": { + "methods": [ + "create_conversation" + ] + }, + "CreateIssueModel": { + "methods": [ + "create_issue_model" + ] + }, + "CreatePhraseMatcher": { + "methods": [ + "create_phrase_matcher" + ] + }, + "CreateView": { + "methods": [ + "create_view" + ] + }, + "DeleteAnalysis": { + "methods": [ + "delete_analysis" + ] + }, + "DeleteConversation": { + "methods": [ + "delete_conversation" + ] + }, + "DeleteIssue": { + "methods": [ + "delete_issue" + ] + }, + "DeleteIssueModel": { + "methods": [ + "delete_issue_model" + ] + }, + "DeletePhraseMatcher": { + "methods": [ + "delete_phrase_matcher" + ] + }, + "DeleteView": { + "methods": [ + "delete_view" + ] + }, + "DeployIssueModel": { + "methods": [ + "deploy_issue_model" + ] + }, + "ExportInsightsData": { + "methods": [ + "export_insights_data" + ] + }, + "GetAnalysis": { + "methods": [ + "get_analysis" + ] + }, + "GetConversation": { + "methods": [ + "get_conversation" + ] + }, + "GetIssue": { + "methods": [ + "get_issue" + ] + }, + "GetIssueModel": { + "methods": [ + "get_issue_model" + ] + }, + "GetPhraseMatcher": { + "methods": [ + "get_phrase_matcher" + ] + }, + "GetSettings": { + "methods": [ + "get_settings" + ] + }, + "GetView": { + "methods": [ + "get_view" + ] + }, + "IngestConversations": { + "methods": [ + "ingest_conversations" + ] + }, + "ListAnalyses": { + "methods": [ + "list_analyses" + ] + }, + "ListConversations": { + "methods": [ + "list_conversations" + ] + }, + "ListIssueModels": { + "methods": [ + "list_issue_models" + ] + }, + "ListIssues": { + "methods": [ + "list_issues" + ] + }, + "ListPhraseMatchers": { + "methods": [ + "list_phrase_matchers" + ] + }, + "ListViews": { + "methods": [ + "list_views" + ] + }, + "UndeployIssueModel": { + "methods": [ + "undeploy_issue_model" + ] + }, + "UpdateConversation": { + "methods": [ + "update_conversation" + ] + }, + "UpdateIssue": { + "methods": [ + "update_issue" + ] + }, + "UpdateIssueModel": { + "methods": [ + "update_issue_model" + ] + }, + "UpdatePhraseMatcher": { + "methods": [ + "update_phrase_matcher" + ] + }, + "UpdateSettings": { + "methods": [ + "update_settings" + ] + }, + "UpdateView": { + "methods": [ + "update_view" + ] + }, + "UploadConversation": { + "methods": [ + "upload_conversation" + ] + } + } + }, + "grpc-async": { + "libraryClient": "ContactCenterInsightsAsyncClient", + "rpcs": { + "BulkAnalyzeConversations": { + "methods": [ + "bulk_analyze_conversations" + ] + }, + "CalculateIssueModelStats": { + "methods": [ + "calculate_issue_model_stats" + ] + }, + "CalculateStats": { + "methods": [ + "calculate_stats" + ] + }, + "CreateAnalysis": { + "methods": [ + "create_analysis" + ] + }, + "CreateConversation": { + "methods": [ + "create_conversation" + ] + }, + "CreateIssueModel": { + "methods": [ + "create_issue_model" + ] + }, + "CreatePhraseMatcher": { + "methods": [ + "create_phrase_matcher" + ] + }, + "CreateView": { + "methods": [ + "create_view" + ] + }, + "DeleteAnalysis": { + "methods": [ + "delete_analysis" + ] + }, + "DeleteConversation": { + "methods": [ + "delete_conversation" + ] + }, + "DeleteIssue": { + "methods": [ + "delete_issue" + ] + }, + "DeleteIssueModel": { + "methods": [ + "delete_issue_model" + ] + }, + "DeletePhraseMatcher": { + "methods": [ + "delete_phrase_matcher" + ] + }, + "DeleteView": { + "methods": [ + "delete_view" + ] + }, + "DeployIssueModel": { + "methods": [ + "deploy_issue_model" + ] + }, + "ExportInsightsData": { + "methods": [ + "export_insights_data" + ] + }, + "GetAnalysis": { + "methods": [ + "get_analysis" + ] + }, + "GetConversation": { + "methods": [ + "get_conversation" + ] + }, + "GetIssue": { + "methods": [ + "get_issue" + ] + }, + "GetIssueModel": { + "methods": [ + "get_issue_model" + ] + }, + "GetPhraseMatcher": { + "methods": [ + "get_phrase_matcher" + ] + }, + "GetSettings": { + "methods": [ + "get_settings" + ] + }, + "GetView": { + "methods": [ + "get_view" + ] + }, + "IngestConversations": { + "methods": [ + "ingest_conversations" + ] + }, + "ListAnalyses": { + "methods": [ + "list_analyses" + ] + }, + "ListConversations": { + "methods": [ + "list_conversations" + ] + }, + "ListIssueModels": { + "methods": [ + "list_issue_models" + ] + }, + "ListIssues": { + "methods": [ + "list_issues" + ] + }, + "ListPhraseMatchers": { + "methods": [ + "list_phrase_matchers" + ] + }, + "ListViews": { + "methods": [ + "list_views" + ] + }, + "UndeployIssueModel": { + "methods": [ + "undeploy_issue_model" + ] + }, + "UpdateConversation": { + "methods": [ + "update_conversation" + ] + }, + "UpdateIssue": { + "methods": [ + "update_issue" + ] + }, + "UpdateIssueModel": { + "methods": [ + "update_issue_model" + ] + }, + "UpdatePhraseMatcher": { + "methods": [ + "update_phrase_matcher" + ] + }, + "UpdateSettings": { + "methods": [ + "update_settings" + ] + }, + "UpdateView": { + "methods": [ + "update_view" + ] + }, + "UploadConversation": { + "methods": [ + "upload_conversation" + ] + } + } + }, + "rest": { + "libraryClient": "ContactCenterInsightsClient", + "rpcs": { + "BulkAnalyzeConversations": { + "methods": [ + "bulk_analyze_conversations" + ] + }, + "CalculateIssueModelStats": { + "methods": [ + "calculate_issue_model_stats" + ] + }, + "CalculateStats": { + "methods": [ + "calculate_stats" + ] + }, + "CreateAnalysis": { + "methods": [ + "create_analysis" + ] + }, + "CreateConversation": { + "methods": [ + "create_conversation" + ] + }, + "CreateIssueModel": { + "methods": [ + "create_issue_model" + ] + }, + "CreatePhraseMatcher": { + "methods": [ + "create_phrase_matcher" + ] + }, + "CreateView": { + "methods": [ + "create_view" + ] + }, + "DeleteAnalysis": { + "methods": [ + "delete_analysis" + ] + }, + "DeleteConversation": { + "methods": [ + "delete_conversation" + ] + }, + "DeleteIssue": { + "methods": [ + "delete_issue" + ] + }, + "DeleteIssueModel": { + "methods": [ + "delete_issue_model" + ] + }, + "DeletePhraseMatcher": { + "methods": [ + "delete_phrase_matcher" + ] + }, + "DeleteView": { + "methods": [ + "delete_view" + ] + }, + "DeployIssueModel": { + "methods": [ + "deploy_issue_model" + ] + }, + "ExportInsightsData": { + "methods": [ + "export_insights_data" + ] + }, + "GetAnalysis": { + "methods": [ + "get_analysis" + ] + }, + "GetConversation": { + "methods": [ + "get_conversation" + ] + }, + "GetIssue": { + "methods": [ + "get_issue" + ] + }, + "GetIssueModel": { + "methods": [ + "get_issue_model" + ] + }, + "GetPhraseMatcher": { + "methods": [ + "get_phrase_matcher" + ] + }, + "GetSettings": { + "methods": [ + "get_settings" + ] + }, + "GetView": { + "methods": [ + "get_view" + ] + }, + "IngestConversations": { + "methods": [ + "ingest_conversations" + ] + }, + "ListAnalyses": { + "methods": [ + "list_analyses" + ] + }, + "ListConversations": { + "methods": [ + "list_conversations" + ] + }, + "ListIssueModels": { + "methods": [ + "list_issue_models" + ] + }, + "ListIssues": { + "methods": [ + "list_issues" + ] + }, + "ListPhraseMatchers": { + "methods": [ + "list_phrase_matchers" + ] + }, + "ListViews": { + "methods": [ + "list_views" + ] + }, + "UndeployIssueModel": { + "methods": [ + "undeploy_issue_model" + ] + }, + "UpdateConversation": { + "methods": [ + "update_conversation" + ] + }, + "UpdateIssue": { + "methods": [ + "update_issue" + ] + }, + "UpdateIssueModel": { + "methods": [ + "update_issue_model" + ] + }, + "UpdatePhraseMatcher": { + "methods": [ + "update_phrase_matcher" + ] + }, + "UpdateSettings": { + "methods": [ + "update_settings" + ] + }, + "UpdateView": { + "methods": [ + "update_view" + ] + }, + "UploadConversation": { + "methods": [ + "upload_conversation" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/gapic_version.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/gapic_version.py new file mode 100644 index 000000000000..360a0d13ebdd --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/gapic_version.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +__version__ = "0.0.0" # {x-release-please-version} diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/py.typed b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/py.typed new file mode 100644 index 000000000000..d02b3b435cbb --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-contact-center-insights package uses inline types. diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/__init__.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/__init__.py new file mode 100644 index 000000000000..89a37dc92c5a --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/__init__.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/__init__.py new file mode 100644 index 000000000000..8c4af4871216 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +from .client import ContactCenterInsightsClient +from .async_client import ContactCenterInsightsAsyncClient + +__all__ = ( + 'ContactCenterInsightsClient', + 'ContactCenterInsightsAsyncClient', +) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py new file mode 100644 index 000000000000..bf79a6deebf0 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py @@ -0,0 +1,4421 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +from collections import OrderedDict +import functools +import re +from typing import Dict, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union + +from google.cloud.contact_center_insights_v1 import gapic_version as package_version + +from google.api_core.client_options import ClientOptions +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.contact_center_insights_v1.services.contact_center_insights import pagers +from google.cloud.contact_center_insights_v1.types import contact_center_insights +from google.cloud.contact_center_insights_v1.types import resources +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import ContactCenterInsightsTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import ContactCenterInsightsGrpcAsyncIOTransport +from .client import ContactCenterInsightsClient + + +class ContactCenterInsightsAsyncClient: + """An API that lets users analyze and explore their business + conversation data. + """ + + _client: ContactCenterInsightsClient + + DEFAULT_ENDPOINT = ContactCenterInsightsClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = ContactCenterInsightsClient.DEFAULT_MTLS_ENDPOINT + + analysis_path = staticmethod(ContactCenterInsightsClient.analysis_path) + parse_analysis_path = staticmethod(ContactCenterInsightsClient.parse_analysis_path) + conversation_path = staticmethod(ContactCenterInsightsClient.conversation_path) + parse_conversation_path = staticmethod(ContactCenterInsightsClient.parse_conversation_path) + conversation_profile_path = staticmethod(ContactCenterInsightsClient.conversation_profile_path) + parse_conversation_profile_path = staticmethod(ContactCenterInsightsClient.parse_conversation_profile_path) + issue_path = staticmethod(ContactCenterInsightsClient.issue_path) + parse_issue_path = staticmethod(ContactCenterInsightsClient.parse_issue_path) + issue_model_path = staticmethod(ContactCenterInsightsClient.issue_model_path) + parse_issue_model_path = staticmethod(ContactCenterInsightsClient.parse_issue_model_path) + participant_path = staticmethod(ContactCenterInsightsClient.participant_path) + parse_participant_path = staticmethod(ContactCenterInsightsClient.parse_participant_path) + phrase_matcher_path = staticmethod(ContactCenterInsightsClient.phrase_matcher_path) + 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) + parse_view_path = staticmethod(ContactCenterInsightsClient.parse_view_path) + common_billing_account_path = staticmethod(ContactCenterInsightsClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(ContactCenterInsightsClient.parse_common_billing_account_path) + common_folder_path = staticmethod(ContactCenterInsightsClient.common_folder_path) + parse_common_folder_path = staticmethod(ContactCenterInsightsClient.parse_common_folder_path) + common_organization_path = staticmethod(ContactCenterInsightsClient.common_organization_path) + parse_common_organization_path = staticmethod(ContactCenterInsightsClient.parse_common_organization_path) + common_project_path = staticmethod(ContactCenterInsightsClient.common_project_path) + parse_common_project_path = staticmethod(ContactCenterInsightsClient.parse_common_project_path) + common_location_path = staticmethod(ContactCenterInsightsClient.common_location_path) + parse_common_location_path = staticmethod(ContactCenterInsightsClient.parse_common_location_path) + + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials + info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + ContactCenterInsightsAsyncClient: The constructed client. + """ + return ContactCenterInsightsClient.from_service_account_info.__func__(ContactCenterInsightsAsyncClient, info, *args, **kwargs) # type: ignore + + @classmethod + def from_service_account_file(cls, filename: str, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + ContactCenterInsightsAsyncClient: The constructed client. + """ + return ContactCenterInsightsClient.from_service_account_file.__func__(ContactCenterInsightsAsyncClient, filename, *args, **kwargs) # type: ignore + + from_service_account_json = from_service_account_file + + @classmethod + def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[ClientOptions] = None): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variable is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return ContactCenterInsightsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + + @property + def transport(self) -> ContactCenterInsightsTransport: + """Returns the transport used by the client instance. + + Returns: + ContactCenterInsightsTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(ContactCenterInsightsClient).get_transport_class, type(ContactCenterInsightsClient)) + + def __init__(self, *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Union[str, ContactCenterInsightsTransport] = "grpc_asyncio", + client_options: Optional[ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the contact center insights client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, ~.ContactCenterInsightsTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (ClientOptions): Custom options for the client. It + won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint) and "auto" (auto switch to the + default mTLS endpoint if client certificate is present, this is + the default value). However, the ``api_endpoint`` property takes + precedence if provided. + (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide client certificate for mutual TLS transport. If + not provided, the default SSL client certificate will be used if + present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not + set, no client certificate will be used. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + """ + self._client = ContactCenterInsightsClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def create_conversation(self, + request: Optional[Union[contact_center_insights.CreateConversationRequest, dict]] = None, + *, + parent: Optional[str] = None, + conversation: Optional[resources.Conversation] = None, + conversation_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Conversation: + r"""Creates a conversation. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_create_conversation(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateConversationRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_conversation(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.CreateConversationRequest, dict]]): + The request object. Request to create a conversation. + parent (:class:`str`): + Required. The parent resource of the + conversation. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + conversation (:class:`google.cloud.contact_center_insights_v1.types.Conversation`): + Required. The conversation resource + to create. + + This corresponds to the ``conversation`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + conversation_id (:class:`str`): + A unique ID for the new conversation. This ID will + become the final component of the conversation's + resource name. If no ID is specified, a server-generated + ID will be used. + + This value should be 4-64 characters and must match the + regular expression ``^[a-z0-9-]{4,64}$``. Valid + characters are ``[a-z][0-9]-`` + + This corresponds to the ``conversation_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Conversation: + The conversation resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, conversation, conversation_id]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.CreateConversationRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if conversation is not None: + request.conversation = conversation + if conversation_id is not None: + request.conversation_id = conversation_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_conversation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def upload_conversation(self, + request: Optional[Union[contact_center_insights.UploadConversationRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Create a longrunning conversation upload operation. + This method differs from CreateConversation by allowing + audio transcription and optional DLP redaction. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_upload_conversation(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UploadConversationRequest( + parent="parent_value", + ) + + # Make the request + operation = client.upload_conversation(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.UploadConversationRequest, dict]]): + The request object. Request to upload a conversation. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.Conversation` + The conversation resource. + + """ + # Create or coerce a protobuf request object. + request = contact_center_insights.UploadConversationRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.upload_conversation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + resources.Conversation, + metadata_type=contact_center_insights.UploadConversationMetadata, + ) + + # Done; return the response. + return response + + async def update_conversation(self, + request: Optional[Union[contact_center_insights.UpdateConversationRequest, dict]] = None, + *, + conversation: Optional[resources.Conversation] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Conversation: + r"""Updates a conversation. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_update_conversation(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateConversationRequest( + ) + + # Make the request + response = await client.update_conversation(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.UpdateConversationRequest, dict]]): + The request object. The request to update a conversation. + conversation (:class:`google.cloud.contact_center_insights_v1.types.Conversation`): + Required. The new values for the + conversation. + + This corresponds to the ``conversation`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Conversation: + The conversation resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([conversation, update_mask]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.UpdateConversationRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if conversation is not None: + request.conversation = conversation + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_conversation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("conversation.name", request.conversation.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_conversation(self, + request: Optional[Union[contact_center_insights.GetConversationRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Conversation: + r"""Gets a conversation. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_get_conversation(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetConversationRequest( + name="name_value", + ) + + # Make the request + response = await client.get_conversation(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetConversationRequest, dict]]): + The request object. The request to get a conversation. + name (:class:`str`): + Required. The name of the + conversation to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Conversation: + The conversation resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.GetConversationRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_conversation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_conversations(self, + request: Optional[Union[contact_center_insights.ListConversationsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListConversationsAsyncPager: + r"""Lists conversations. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_list_conversations(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListConversationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_conversations(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.ListConversationsRequest, dict]]): + The request object. Request to list conversations. + parent (:class:`str`): + Required. The parent resource of the + conversation. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListConversationsAsyncPager: + The response of listing + conversations. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.ListConversationsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_conversations, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListConversationsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_conversation(self, + request: Optional[Union[contact_center_insights.DeleteConversationRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a conversation. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_delete_conversation(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteConversationRequest( + name="name_value", + ) + + # Make the request + await client.delete_conversation(request=request) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeleteConversationRequest, dict]]): + The request object. The request to delete a conversation. + name (:class:`str`): + Required. The name of the + conversation to delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.DeleteConversationRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.delete_conversation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def create_analysis(self, + request: Optional[Union[contact_center_insights.CreateAnalysisRequest, dict]] = None, + *, + parent: Optional[str] = None, + analysis: Optional[resources.Analysis] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates an analysis. The long running operation is + done when the analysis has completed. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_create_analysis(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateAnalysisRequest( + parent="parent_value", + ) + + # Make the request + operation = client.create_analysis(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.CreateAnalysisRequest, dict]]): + The request object. The request to create an analysis. + parent (:class:`str`): + Required. The parent resource of the + analysis. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + analysis (:class:`google.cloud.contact_center_insights_v1.types.Analysis`): + Required. The analysis to create. + This corresponds to the ``analysis`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.Analysis` + The analysis resource. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, analysis]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.CreateAnalysisRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if analysis is not None: + request.analysis = analysis + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_analysis, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + resources.Analysis, + metadata_type=contact_center_insights.CreateAnalysisOperationMetadata, + ) + + # Done; return the response. + return response + + async def get_analysis(self, + request: Optional[Union[contact_center_insights.GetAnalysisRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Analysis: + r"""Gets an analysis. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_get_analysis(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetAnalysisRequest( + name="name_value", + ) + + # Make the request + response = await client.get_analysis(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetAnalysisRequest, dict]]): + The request object. The request to get an analysis. + name (:class:`str`): + Required. The name of the analysis to + get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Analysis: + The analysis resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.GetAnalysisRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_analysis, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_analyses(self, + request: Optional[Union[contact_center_insights.ListAnalysesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListAnalysesAsyncPager: + r"""Lists analyses. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_list_analyses(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListAnalysesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_analyses(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.ListAnalysesRequest, dict]]): + The request object. The request to list analyses. + parent (:class:`str`): + Required. The parent resource of the + analyses. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAnalysesAsyncPager: + The response to list analyses. + + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.ListAnalysesRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_analyses, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListAnalysesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_analysis(self, + request: Optional[Union[contact_center_insights.DeleteAnalysisRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes an analysis. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_delete_analysis(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteAnalysisRequest( + name="name_value", + ) + + # Make the request + await client.delete_analysis(request=request) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeleteAnalysisRequest, dict]]): + The request object. The request to delete an analysis. + name (:class:`str`): + Required. The name of the analysis to + delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.DeleteAnalysisRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.delete_analysis, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def bulk_analyze_conversations(self, + request: Optional[Union[contact_center_insights.BulkAnalyzeConversationsRequest, dict]] = None, + *, + parent: Optional[str] = None, + filter: Optional[str] = None, + analysis_percentage: Optional[float] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Analyzes multiple conversations in a single request. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_bulk_analyze_conversations(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.BulkAnalyzeConversationsRequest( + parent="parent_value", + filter="filter_value", + analysis_percentage=0.20170000000000002, + ) + + # Make the request + operation = client.bulk_analyze_conversations(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.BulkAnalyzeConversationsRequest, dict]]): + The request object. The request to analyze conversations + in bulk. + parent (:class:`str`): + Required. The parent resource to + create analyses in. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + filter (:class:`str`): + Required. Filter used to select the + subset of conversations to analyze. + + This corresponds to the ``filter`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + analysis_percentage (:class:`float`): + Required. Percentage of selected conversation to + analyze, between [0, 100]. + + This corresponds to the ``analysis_percentage`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.BulkAnalyzeConversationsResponse` + The response for a bulk analyze conversations operation. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, filter, analysis_percentage]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.BulkAnalyzeConversationsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if filter is not None: + request.filter = filter + if analysis_percentage is not None: + request.analysis_percentage = analysis_percentage + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.bulk_analyze_conversations, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + contact_center_insights.BulkAnalyzeConversationsResponse, + metadata_type=contact_center_insights.BulkAnalyzeConversationsMetadata, + ) + + # Done; return the response. + return response + + async def ingest_conversations(self, + request: Optional[Union[contact_center_insights.IngestConversationsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Imports conversations and processes them according to + the user's configuration. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_ingest_conversations(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + gcs_source = contact_center_insights_v1.GcsSource() + gcs_source.bucket_uri = "bucket_uri_value" + + transcript_object_config = contact_center_insights_v1.TranscriptObjectConfig() + transcript_object_config.medium = "CHAT" + + request = contact_center_insights_v1.IngestConversationsRequest( + gcs_source=gcs_source, + transcript_object_config=transcript_object_config, + parent="parent_value", + ) + + # Make the request + operation = client.ingest_conversations(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.IngestConversationsRequest, dict]]): + The request object. The request to ingest conversations. + parent (:class:`str`): + Required. The parent resource for new + conversations. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.IngestConversationsResponse` + The response to an IngestConversations operation. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.IngestConversationsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.ingest_conversations, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + contact_center_insights.IngestConversationsResponse, + metadata_type=contact_center_insights.IngestConversationsMetadata, + ) + + # Done; return the response. + return response + + async def export_insights_data(self, + request: Optional[Union[contact_center_insights.ExportInsightsDataRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Export insights data to a destination defined in the + request body. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_export_insights_data(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + big_query_destination = contact_center_insights_v1.BigQueryDestination() + big_query_destination.dataset = "dataset_value" + + request = contact_center_insights_v1.ExportInsightsDataRequest( + big_query_destination=big_query_destination, + parent="parent_value", + ) + + # Make the request + operation = client.export_insights_data(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest, dict]]): + The request object. The request to export insights. + parent (:class:`str`): + Required. The parent resource to + export data from. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.ExportInsightsDataResponse` + Response for an export insights operation. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.ExportInsightsDataRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.export_insights_data, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + contact_center_insights.ExportInsightsDataResponse, + metadata_type=contact_center_insights.ExportInsightsDataMetadata, + ) + + # Done; return the response. + return response + + async def create_issue_model(self, + request: Optional[Union[contact_center_insights.CreateIssueModelRequest, dict]] = None, + *, + parent: Optional[str] = None, + issue_model: Optional[resources.IssueModel] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates an issue model. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_create_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateIssueModelRequest( + parent="parent_value", + ) + + # Make the request + operation = client.create_issue_model(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.CreateIssueModelRequest, dict]]): + The request object. The request to create an issue model. + parent (:class:`str`): + Required. The parent resource of the + issue model. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + issue_model (:class:`google.cloud.contact_center_insights_v1.types.IssueModel`): + Required. The issue model to create. + This corresponds to the ``issue_model`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.IssueModel` + The issue model resource. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, issue_model]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.CreateIssueModelRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if issue_model is not None: + request.issue_model = issue_model + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_issue_model, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + resources.IssueModel, + metadata_type=contact_center_insights.CreateIssueModelMetadata, + ) + + # Done; return the response. + return response + + async def update_issue_model(self, + request: Optional[Union[contact_center_insights.UpdateIssueModelRequest, dict]] = None, + *, + issue_model: Optional[resources.IssueModel] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.IssueModel: + r"""Updates an issue model. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_update_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateIssueModelRequest( + ) + + # Make the request + response = await client.update_issue_model(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.UpdateIssueModelRequest, dict]]): + The request object. The request to update an issue model. + issue_model (:class:`google.cloud.contact_center_insights_v1.types.IssueModel`): + Required. The new values for the + issue model. + + This corresponds to the ``issue_model`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.IssueModel: + The issue model resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([issue_model, update_mask]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.UpdateIssueModelRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if issue_model is not None: + request.issue_model = issue_model + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_issue_model, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("issue_model.name", request.issue_model.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_issue_model(self, + request: Optional[Union[contact_center_insights.GetIssueModelRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.IssueModel: + r"""Gets an issue model. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_get_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetIssueModelRequest( + name="name_value", + ) + + # Make the request + response = await client.get_issue_model(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetIssueModelRequest, dict]]): + The request object. The request to get an issue model. + name (:class:`str`): + Required. The name of the issue model + to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.IssueModel: + The issue model resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.GetIssueModelRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_issue_model, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_issue_models(self, + request: Optional[Union[contact_center_insights.ListIssueModelsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> contact_center_insights.ListIssueModelsResponse: + r"""Lists issue models. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_list_issue_models(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListIssueModelsRequest( + parent="parent_value", + ) + + # Make the request + response = await client.list_issue_models(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.ListIssueModelsRequest, dict]]): + The request object. Request to list issue models. + parent (:class:`str`): + Required. The parent resource of the + issue model. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.ListIssueModelsResponse: + The response of listing issue models. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.ListIssueModelsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_issue_models, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_issue_model(self, + request: Optional[Union[contact_center_insights.DeleteIssueModelRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Deletes an issue model. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_delete_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteIssueModelRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_issue_model(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeleteIssueModelRequest, dict]]): + The request object. The request to delete an issue model. + name (:class:`str`): + Required. The name of the issue model + to delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.DeleteIssueModelRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.delete_issue_model, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=contact_center_insights.DeleteIssueModelMetadata, + ) + + # Done; return the response. + return response + + async def deploy_issue_model(self, + request: Optional[Union[contact_center_insights.DeployIssueModelRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Deploys an issue model. Returns an error if a model + is already deployed. An issue model can only be used in + analysis after it has been deployed. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_deploy_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeployIssueModelRequest( + name="name_value", + ) + + # Make the request + operation = client.deploy_issue_model(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeployIssueModelRequest, dict]]): + The request object. The request to deploy an issue model. + name (:class:`str`): + Required. The issue model to deploy. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.DeployIssueModelResponse` + The response to deploy an issue model. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.DeployIssueModelRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.deploy_issue_model, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + contact_center_insights.DeployIssueModelResponse, + metadata_type=contact_center_insights.DeployIssueModelMetadata, + ) + + # Done; return the response. + return response + + async def undeploy_issue_model(self, + request: Optional[Union[contact_center_insights.UndeployIssueModelRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Undeploys an issue model. + An issue model can not be used in analysis after it has + been undeployed. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_undeploy_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UndeployIssueModelRequest( + name="name_value", + ) + + # Make the request + operation = client.undeploy_issue_model(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.UndeployIssueModelRequest, dict]]): + The request object. The request to undeploy an issue + model. + name (:class:`str`): + Required. The issue model to + undeploy. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.UndeployIssueModelResponse` + The response to undeploy an issue model. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.UndeployIssueModelRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.undeploy_issue_model, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + contact_center_insights.UndeployIssueModelResponse, + metadata_type=contact_center_insights.UndeployIssueModelMetadata, + ) + + # Done; return the response. + return response + + async def get_issue(self, + request: Optional[Union[contact_center_insights.GetIssueRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Issue: + r"""Gets an issue. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_get_issue(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetIssueRequest( + name="name_value", + ) + + # Make the request + response = await client.get_issue(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetIssueRequest, dict]]): + The request object. The request to get an issue. + name (:class:`str`): + Required. The name of the issue to + get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Issue: + The issue resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.GetIssueRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_issue, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_issues(self, + request: Optional[Union[contact_center_insights.ListIssuesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> contact_center_insights.ListIssuesResponse: + r"""Lists issues. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_list_issues(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListIssuesRequest( + parent="parent_value", + ) + + # Make the request + response = await client.list_issues(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.ListIssuesRequest, dict]]): + The request object. Request to list issues. + parent (:class:`str`): + Required. The parent resource of the + issue. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.ListIssuesResponse: + The response of listing issues. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.ListIssuesRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_issues, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_issue(self, + request: Optional[Union[contact_center_insights.UpdateIssueRequest, dict]] = None, + *, + issue: Optional[resources.Issue] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Issue: + r"""Updates an issue. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_update_issue(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateIssueRequest( + ) + + # Make the request + response = await client.update_issue(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.UpdateIssueRequest, dict]]): + The request object. The request to update an issue. + issue (:class:`google.cloud.contact_center_insights_v1.types.Issue`): + Required. The new values for the + issue. + + This corresponds to the ``issue`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Issue: + The issue resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([issue, update_mask]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.UpdateIssueRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if issue is not None: + request.issue = issue + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_issue, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("issue.name", request.issue.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_issue(self, + request: Optional[Union[contact_center_insights.DeleteIssueRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes an issue. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_delete_issue(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteIssueRequest( + name="name_value", + ) + + # Make the request + await client.delete_issue(request=request) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeleteIssueRequest, dict]]): + The request object. The request to delete an issue. + name (:class:`str`): + Required. The name of the issue to + delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.DeleteIssueRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.delete_issue, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def calculate_issue_model_stats(self, + request: Optional[Union[contact_center_insights.CalculateIssueModelStatsRequest, dict]] = None, + *, + issue_model: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> contact_center_insights.CalculateIssueModelStatsResponse: + r"""Gets an issue model's statistics. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_calculate_issue_model_stats(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CalculateIssueModelStatsRequest( + issue_model="issue_model_value", + ) + + # Make the request + response = await client.calculate_issue_model_stats(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsRequest, dict]]): + The request object. Request to get statistics of an issue + model. + issue_model (:class:`str`): + Required. The resource name of the + issue model to query against. + + This corresponds to the ``issue_model`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsResponse: + Response of querying an issue model's + statistics. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([issue_model]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.CalculateIssueModelStatsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if issue_model is not None: + request.issue_model = issue_model + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.calculate_issue_model_stats, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("issue_model", request.issue_model), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_phrase_matcher(self, + request: Optional[Union[contact_center_insights.CreatePhraseMatcherRequest, dict]] = None, + *, + parent: Optional[str] = None, + phrase_matcher: Optional[resources.PhraseMatcher] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.PhraseMatcher: + r"""Creates a phrase matcher. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_create_phrase_matcher(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + phrase_matcher = contact_center_insights_v1.PhraseMatcher() + phrase_matcher.type_ = "ANY_OF" + + request = contact_center_insights_v1.CreatePhraseMatcherRequest( + parent="parent_value", + phrase_matcher=phrase_matcher, + ) + + # Make the request + response = await client.create_phrase_matcher(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.CreatePhraseMatcherRequest, dict]]): + The request object. Request to create a phrase matcher. + parent (:class:`str`): + Required. The parent resource of the phrase matcher. + Required. The location to create a phrase matcher for. + Format: + ``projects//locations/`` or + ``projects//locations/`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + phrase_matcher (:class:`google.cloud.contact_center_insights_v1.types.PhraseMatcher`): + Required. The phrase matcher resource + to create. + + This corresponds to the ``phrase_matcher`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.PhraseMatcher: + The phrase matcher resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, phrase_matcher]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.CreatePhraseMatcherRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if phrase_matcher is not None: + request.phrase_matcher = phrase_matcher + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_phrase_matcher, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_phrase_matcher(self, + request: Optional[Union[contact_center_insights.GetPhraseMatcherRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.PhraseMatcher: + r"""Gets a phrase matcher. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_get_phrase_matcher(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetPhraseMatcherRequest( + name="name_value", + ) + + # Make the request + response = await client.get_phrase_matcher(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetPhraseMatcherRequest, dict]]): + The request object. The request to get a a phrase + matcher. + name (:class:`str`): + Required. The name of the phrase + matcher to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.PhraseMatcher: + The phrase matcher resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.GetPhraseMatcherRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_phrase_matcher, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_phrase_matchers(self, + request: Optional[Union[contact_center_insights.ListPhraseMatchersRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListPhraseMatchersAsyncPager: + r"""Lists phrase matchers. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_list_phrase_matchers(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListPhraseMatchersRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_phrase_matchers(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.ListPhraseMatchersRequest, dict]]): + The request object. Request to list phrase matchers. + parent (:class:`str`): + Required. The parent resource of the + phrase matcher. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListPhraseMatchersAsyncPager: + The response of listing phrase + matchers. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.ListPhraseMatchersRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_phrase_matchers, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListPhraseMatchersAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_phrase_matcher(self, + request: Optional[Union[contact_center_insights.DeletePhraseMatcherRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a phrase matcher. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_delete_phrase_matcher(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeletePhraseMatcherRequest( + name="name_value", + ) + + # Make the request + await client.delete_phrase_matcher(request=request) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeletePhraseMatcherRequest, dict]]): + The request object. The request to delete a phrase + matcher. + name (:class:`str`): + Required. The name of the phrase + matcher to delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.DeletePhraseMatcherRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.delete_phrase_matcher, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def update_phrase_matcher(self, + request: Optional[Union[contact_center_insights.UpdatePhraseMatcherRequest, dict]] = None, + *, + phrase_matcher: Optional[resources.PhraseMatcher] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.PhraseMatcher: + r"""Updates a phrase matcher. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_update_phrase_matcher(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + phrase_matcher = contact_center_insights_v1.PhraseMatcher() + phrase_matcher.type_ = "ANY_OF" + + request = contact_center_insights_v1.UpdatePhraseMatcherRequest( + phrase_matcher=phrase_matcher, + ) + + # Make the request + response = await client.update_phrase_matcher(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.UpdatePhraseMatcherRequest, dict]]): + The request object. The request to update a phrase + matcher. + phrase_matcher (:class:`google.cloud.contact_center_insights_v1.types.PhraseMatcher`): + Required. The new values for the + phrase matcher. + + This corresponds to the ``phrase_matcher`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.PhraseMatcher: + The phrase matcher resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([phrase_matcher, update_mask]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.UpdatePhraseMatcherRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if phrase_matcher is not None: + request.phrase_matcher = phrase_matcher + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_phrase_matcher, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("phrase_matcher.name", request.phrase_matcher.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def calculate_stats(self, + request: Optional[Union[contact_center_insights.CalculateStatsRequest, dict]] = None, + *, + location: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> contact_center_insights.CalculateStatsResponse: + r"""Gets conversation statistics. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_calculate_stats(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CalculateStatsRequest( + location="location_value", + ) + + # Make the request + response = await client.calculate_stats(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.CalculateStatsRequest, dict]]): + The request object. The request for calculating + conversation statistics. + location (:class:`str`): + Required. The location of the + conversations. + + This corresponds to the ``location`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.CalculateStatsResponse: + The response for calculating + conversation statistics. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([location]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.CalculateStatsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if location is not None: + request.location = location + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.calculate_stats, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("location", request.location), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_settings(self, + request: Optional[Union[contact_center_insights.GetSettingsRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Settings: + r"""Gets project-level settings. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_get_settings(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetSettingsRequest( + name="name_value", + ) + + # Make the request + response = await client.get_settings(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetSettingsRequest, dict]]): + The request object. The request to get project-level + settings. + name (:class:`str`): + Required. The name of the settings + resource to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Settings: + The settings resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.GetSettingsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_settings, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_settings(self, + request: Optional[Union[contact_center_insights.UpdateSettingsRequest, dict]] = None, + *, + settings: Optional[resources.Settings] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Settings: + r"""Updates project-level settings. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_update_settings(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateSettingsRequest( + ) + + # Make the request + response = await client.update_settings(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.UpdateSettingsRequest, dict]]): + The request object. The request to update project-level + settings. + settings (:class:`google.cloud.contact_center_insights_v1.types.Settings`): + Required. The new settings values. + This corresponds to the ``settings`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The list of fields to be + updated. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Settings: + The settings resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([settings, update_mask]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.UpdateSettingsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if settings is not None: + request.settings = settings + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_settings, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("settings.name", request.settings.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_view(self, + request: Optional[Union[contact_center_insights.CreateViewRequest, dict]] = None, + *, + parent: Optional[str] = None, + view: Optional[resources.View] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.View: + r"""Creates a view. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_create_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateViewRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_view(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.CreateViewRequest, dict]]): + The request object. The request to create a view. + parent (:class:`str`): + Required. The parent resource of the view. Required. The + location to create a view for. Format: + ``projects//locations/`` or + ``projects//locations/`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + view (:class:`google.cloud.contact_center_insights_v1.types.View`): + Required. The view resource to + create. + + This corresponds to the ``view`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.View: + The View resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, view]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.CreateViewRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if view is not None: + request.view = view + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_view, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_view(self, + request: Optional[Union[contact_center_insights.GetViewRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.View: + r"""Gets a view. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_get_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetViewRequest( + name="name_value", + ) + + # Make the request + response = await client.get_view(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetViewRequest, dict]]): + The request object. The request to get a view. + name (:class:`str`): + Required. The name of the view to + get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.View: + The View resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.GetViewRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_view, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_views(self, + request: Optional[Union[contact_center_insights.ListViewsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListViewsAsyncPager: + r"""Lists views. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_list_views(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListViewsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_views(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.ListViewsRequest, dict]]): + The request object. The request to list views. + parent (:class:`str`): + Required. The parent resource of the + views. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListViewsAsyncPager: + The response of listing views. + + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.ListViewsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_views, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListViewsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_view(self, + request: Optional[Union[contact_center_insights.UpdateViewRequest, dict]] = None, + *, + view: Optional[resources.View] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.View: + r"""Updates a view. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_update_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateViewRequest( + ) + + # Make the request + response = await client.update_view(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.UpdateViewRequest, dict]]): + The request object. The request to update a view. + view (:class:`google.cloud.contact_center_insights_v1.types.View`): + Required. The new view. + This corresponds to the ``view`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.View: + The View resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([view, update_mask]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.UpdateViewRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if view is not None: + request.view = view + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_view, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("view.name", request.view.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_view(self, + request: Optional[Union[contact_center_insights.DeleteViewRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a view. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + async def sample_delete_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteViewRequest( + name="name_value", + ) + + # Make the request + await client.delete_view(request=request) + + Args: + request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeleteViewRequest, dict]]): + The request object. The request to delete a view. + name (:class:`str`): + Required. The name of the view to + delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + request = contact_center_insights.DeleteViewRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.delete_view, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def list_operations( + self, + request: Optional[operations_pb2.ListOperationsRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.ListOperationsResponse: + r"""Lists operations that match the specified filter in the request. + + Args: + request (:class:`~.operations_pb2.ListOperationsRequest`): + The request object. Request message for + `ListOperations` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + ~.operations_pb2.ListOperationsResponse: + Response message for ``ListOperations`` method. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.ListOperationsRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._client._transport.list_operations, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def get_operation( + self, + request: Optional[operations_pb2.GetOperationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Gets the latest state of a long-running operation. + + Args: + request (:class:`~.operations_pb2.GetOperationRequest`): + The request object. Request message for + `GetOperation` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + ~.operations_pb2.Operation: + An ``Operation`` object. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.GetOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._client._transport.get_operation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def cancel_operation( + self, + request: Optional[operations_pb2.CancelOperationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Starts asynchronous cancellation on a long-running operation. + + The server makes a best effort to cancel the operation, but success + is not guaranteed. If the server doesn't support this method, it returns + `google.rpc.Code.UNIMPLEMENTED`. + + Args: + request (:class:`~.operations_pb2.CancelOperationRequest`): + The request object. Request message for + `CancelOperation` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + None + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.CancelOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._client._transport.cancel_operation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("name", request.name),)), + ) + + # Send the request. + await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + async def __aenter__(self) -> "ContactCenterInsightsAsyncClient": + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) + + +__all__ = ( + "ContactCenterInsightsAsyncClient", +) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py new file mode 100644 index 000000000000..fbd921cbf054 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py @@ -0,0 +1,4707 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +from collections import OrderedDict +import os +import re +from typing import Dict, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union, cast + +from google.cloud.contact_center_insights_v1 import gapic_version as package_version + +from google.api_core import client_options as client_options_lib +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.contact_center_insights_v1.services.contact_center_insights import pagers +from google.cloud.contact_center_insights_v1.types import contact_center_insights +from google.cloud.contact_center_insights_v1.types import resources +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import ContactCenterInsightsTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import ContactCenterInsightsGrpcTransport +from .transports.grpc_asyncio import ContactCenterInsightsGrpcAsyncIOTransport +from .transports.rest import ContactCenterInsightsRestTransport + + +class ContactCenterInsightsClientMeta(type): + """Metaclass for the ContactCenterInsights client. + + This provides class-level methods for building and retrieving + support objects (e.g. transport) without polluting the client instance + objects. + """ + _transport_registry = OrderedDict() # type: Dict[str, Type[ContactCenterInsightsTransport]] + _transport_registry["grpc"] = ContactCenterInsightsGrpcTransport + _transport_registry["grpc_asyncio"] = ContactCenterInsightsGrpcAsyncIOTransport + _transport_registry["rest"] = ContactCenterInsightsRestTransport + + def get_transport_class(cls, + label: Optional[str] = None, + ) -> Type[ContactCenterInsightsTransport]: + """Returns an appropriate transport class. + + Args: + label: The name of the desired transport. If none is + provided, then the first transport in the registry is used. + + Returns: + The transport class to use. + """ + # If a specific transport is requested, return that one. + if label: + return cls._transport_registry[label] + + # No transport is requested; return the default (that is, the first one + # in the dictionary). + return next(iter(cls._transport_registry.values())) + + +class ContactCenterInsightsClient(metaclass=ContactCenterInsightsClientMeta): + """An API that lets users analyze and explore their business + conversation data. + """ + + @staticmethod + def _get_default_mtls_endpoint(api_endpoint): + """Converts api endpoint to mTLS endpoint. + + Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to + "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. + Args: + api_endpoint (Optional[str]): the api endpoint to convert. + Returns: + str: converted mTLS api endpoint. + """ + if not api_endpoint: + return api_endpoint + + mtls_endpoint_re = re.compile( + r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" + ) + + m = mtls_endpoint_re.match(api_endpoint) + name, mtls, sandbox, googledomain = m.groups() + if mtls or not googledomain: + return api_endpoint + + if sandbox: + return api_endpoint.replace( + "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" + ) + + return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") + + DEFAULT_ENDPOINT = "contactcenterinsights.googleapis.com" + DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore + DEFAULT_ENDPOINT + ) + + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials + info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + ContactCenterInsightsClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_info(info) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + @classmethod + def from_service_account_file(cls, filename: str, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + ContactCenterInsightsClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_file( + filename) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + from_service_account_json = from_service_account_file + + @property + def transport(self) -> ContactCenterInsightsTransport: + """Returns the transport used by the client instance. + + Returns: + ContactCenterInsightsTransport: The transport used by the client + instance. + """ + return self._transport + + @staticmethod + def analysis_path(project: str,location: str,conversation: str,analysis: str,) -> str: + """Returns a fully-qualified analysis string.""" + return "projects/{project}/locations/{location}/conversations/{conversation}/analyses/{analysis}".format(project=project, location=location, conversation=conversation, analysis=analysis, ) + + @staticmethod + def parse_analysis_path(path: str) -> Dict[str,str]: + """Parses a analysis path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/conversations/(?P.+?)/analyses/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def conversation_path(project: str,location: str,conversation: str,) -> str: + """Returns a fully-qualified conversation string.""" + return "projects/{project}/locations/{location}/conversations/{conversation}".format(project=project, location=location, conversation=conversation, ) + + @staticmethod + def parse_conversation_path(path: str) -> Dict[str,str]: + """Parses a conversation path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/conversations/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def conversation_profile_path(project: str,location: str,conversation_profile: str,) -> str: + """Returns a fully-qualified conversation_profile string.""" + return "projects/{project}/locations/{location}/conversationProfiles/{conversation_profile}".format(project=project, location=location, conversation_profile=conversation_profile, ) + + @staticmethod + def parse_conversation_profile_path(path: str) -> Dict[str,str]: + """Parses a conversation_profile path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/conversationProfiles/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def issue_path(project: str,location: str,issue_model: str,issue: str,) -> str: + """Returns a fully-qualified issue string.""" + return "projects/{project}/locations/{location}/issueModels/{issue_model}/issues/{issue}".format(project=project, location=location, issue_model=issue_model, issue=issue, ) + + @staticmethod + def parse_issue_path(path: str) -> Dict[str,str]: + """Parses a issue path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/issueModels/(?P.+?)/issues/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def issue_model_path(project: str,location: str,issue_model: str,) -> str: + """Returns a fully-qualified issue_model string.""" + return "projects/{project}/locations/{location}/issueModels/{issue_model}".format(project=project, location=location, issue_model=issue_model, ) + + @staticmethod + def parse_issue_model_path(path: str) -> Dict[str,str]: + """Parses a issue_model path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/issueModels/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def participant_path(project: str,conversation: str,participant: str,) -> str: + """Returns a fully-qualified participant string.""" + return "projects/{project}/conversations/{conversation}/participants/{participant}".format(project=project, conversation=conversation, participant=participant, ) + + @staticmethod + def parse_participant_path(path: str) -> Dict[str,str]: + """Parses a participant path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/conversations/(?P.+?)/participants/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def phrase_matcher_path(project: str,location: str,phrase_matcher: str,) -> str: + """Returns a fully-qualified phrase_matcher string.""" + return "projects/{project}/locations/{location}/phraseMatchers/{phrase_matcher}".format(project=project, location=location, phrase_matcher=phrase_matcher, ) + + @staticmethod + def parse_phrase_matcher_path(path: str) -> Dict[str,str]: + """Parses a phrase_matcher path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/phraseMatchers/(?P.+?)$", path) + 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,location: str,) -> str: + """Returns a fully-qualified settings string.""" + return "projects/{project}/locations/{location}/settings".format(project=project, location=location, ) + + @staticmethod + def parse_settings_path(path: str) -> Dict[str,str]: + """Parses a settings path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/settings$", path) + return m.groupdict() if m else {} + + @staticmethod + def view_path(project: str,location: str,view: str,) -> str: + """Returns a fully-qualified view string.""" + return "projects/{project}/locations/{location}/views/{view}".format(project=project, location=location, view=view, ) + + @staticmethod + def parse_view_path(path: str) -> Dict[str,str]: + """Parses a view path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/views/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_billing_account_path(billing_account: str, ) -> str: + """Returns a fully-qualified billing_account string.""" + return "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + + @staticmethod + def parse_common_billing_account_path(path: str) -> Dict[str,str]: + """Parse a billing_account path into its component segments.""" + m = re.match(r"^billingAccounts/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_folder_path(folder: str, ) -> str: + """Returns a fully-qualified folder string.""" + return "folders/{folder}".format(folder=folder, ) + + @staticmethod + def parse_common_folder_path(path: str) -> Dict[str,str]: + """Parse a folder path into its component segments.""" + m = re.match(r"^folders/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_organization_path(organization: str, ) -> str: + """Returns a fully-qualified organization string.""" + return "organizations/{organization}".format(organization=organization, ) + + @staticmethod + def parse_common_organization_path(path: str) -> Dict[str,str]: + """Parse a organization path into its component segments.""" + m = re.match(r"^organizations/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_project_path(project: str, ) -> str: + """Returns a fully-qualified project string.""" + return "projects/{project}".format(project=project, ) + + @staticmethod + def parse_common_project_path(path: str) -> Dict[str,str]: + """Parse a project path into its component segments.""" + m = re.match(r"^projects/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_location_path(project: str, location: str, ) -> str: + """Returns a fully-qualified location string.""" + return "projects/{project}/locations/{location}".format(project=project, location=location, ) + + @staticmethod + def parse_common_location_path(path: str) -> Dict[str,str]: + """Parse a location path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) + return m.groupdict() if m else {} + + @classmethod + def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[client_options_lib.ClientOptions] = None): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variable is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError("Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`") + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError("Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`") + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + + def __init__(self, *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Optional[Union[str, ContactCenterInsightsTransport]] = None, + client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the contact center insights client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, ContactCenterInsightsTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the + client. It won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint) and "auto" (auto switch to the + default mTLS endpoint if client certificate is present, this is + the default value). However, the ``api_endpoint`` property takes + precedence if provided. + (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide client certificate for mutual TLS transport. If + not provided, the default SSL client certificate will be used if + present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not + set, no client certificate will be used. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + """ + if isinstance(client_options, dict): + client_options = client_options_lib.from_dict(client_options) + if client_options is None: + client_options = client_options_lib.ClientOptions() + client_options = cast(client_options_lib.ClientOptions, client_options) + + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source(client_options) + + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError("client_options.api_key and credentials are mutually exclusive") + + # Save or instantiate the transport. + # Ordinarily, we provide the transport, but allowing a custom transport + # instance provides an extensibility point for unusual situations. + if isinstance(transport, ContactCenterInsightsTransport): + # transport is a ContactCenterInsightsTransport instance. + if credentials or client_options.credentials_file or api_key_value: + raise ValueError("When providing a transport instance, " + "provide its credentials directly.") + if client_options.scopes: + raise ValueError( + "When providing a transport instance, provide its scopes " + "directly." + ) + self._transport = transport + else: + import google.auth._default # type: ignore + + if api_key_value and hasattr(google.auth._default, "get_api_key_credentials"): + credentials = google.auth._default.get_api_key_credentials(api_key_value) + + Transport = type(self).get_transport_class(transport) + self._transport = Transport( + credentials=credentials, + credentials_file=client_options.credentials_file, + host=api_endpoint, + scopes=client_options.scopes, + client_cert_source_for_mtls=client_cert_source_func, + quota_project_id=client_options.quota_project_id, + client_info=client_info, + always_use_jwt_access=True, + api_audience=client_options.api_audience, + ) + + def create_conversation(self, + request: Optional[Union[contact_center_insights.CreateConversationRequest, dict]] = None, + *, + parent: Optional[str] = None, + conversation: Optional[resources.Conversation] = None, + conversation_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Conversation: + r"""Creates a conversation. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_create_conversation(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateConversationRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_conversation(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CreateConversationRequest, dict]): + The request object. Request to create a conversation. + parent (str): + Required. The parent resource of the + conversation. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + conversation (google.cloud.contact_center_insights_v1.types.Conversation): + Required. The conversation resource + to create. + + This corresponds to the ``conversation`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + conversation_id (str): + A unique ID for the new conversation. This ID will + become the final component of the conversation's + resource name. If no ID is specified, a server-generated + ID will be used. + + This value should be 4-64 characters and must match the + regular expression ``^[a-z0-9-]{4,64}$``. Valid + characters are ``[a-z][0-9]-`` + + This corresponds to the ``conversation_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Conversation: + The conversation resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, conversation, conversation_id]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.CreateConversationRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.CreateConversationRequest): + request = contact_center_insights.CreateConversationRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if conversation is not None: + request.conversation = conversation + if conversation_id is not None: + request.conversation_id = conversation_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_conversation] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def upload_conversation(self, + request: Optional[Union[contact_center_insights.UploadConversationRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Create a longrunning conversation upload operation. + This method differs from CreateConversation by allowing + audio transcription and optional DLP redaction. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_upload_conversation(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UploadConversationRequest( + parent="parent_value", + ) + + # Make the request + operation = client.upload_conversation(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UploadConversationRequest, dict]): + The request object. Request to upload a conversation. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.Conversation` + The conversation resource. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.UploadConversationRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.UploadConversationRequest): + request = contact_center_insights.UploadConversationRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.upload_conversation] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + resources.Conversation, + metadata_type=contact_center_insights.UploadConversationMetadata, + ) + + # Done; return the response. + return response + + def update_conversation(self, + request: Optional[Union[contact_center_insights.UpdateConversationRequest, dict]] = None, + *, + conversation: Optional[resources.Conversation] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Conversation: + r"""Updates a conversation. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_update_conversation(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateConversationRequest( + ) + + # Make the request + response = client.update_conversation(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdateConversationRequest, dict]): + The request object. The request to update a conversation. + conversation (google.cloud.contact_center_insights_v1.types.Conversation): + Required. The new values for the + conversation. + + This corresponds to the ``conversation`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Conversation: + The conversation resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([conversation, update_mask]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.UpdateConversationRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.UpdateConversationRequest): + request = contact_center_insights.UpdateConversationRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if conversation is not None: + request.conversation = conversation + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_conversation] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("conversation.name", request.conversation.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_conversation(self, + request: Optional[Union[contact_center_insights.GetConversationRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Conversation: + r"""Gets a conversation. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_get_conversation(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetConversationRequest( + name="name_value", + ) + + # Make the request + response = client.get_conversation(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetConversationRequest, dict]): + The request object. The request to get a conversation. + name (str): + Required. The name of the + conversation to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Conversation: + The conversation resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.GetConversationRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.GetConversationRequest): + request = contact_center_insights.GetConversationRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_conversation] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_conversations(self, + request: Optional[Union[contact_center_insights.ListConversationsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListConversationsPager: + r"""Lists conversations. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_list_conversations(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListConversationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_conversations(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListConversationsRequest, dict]): + The request object. Request to list conversations. + parent (str): + Required. The parent resource of the + conversation. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListConversationsPager: + The response of listing + conversations. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.ListConversationsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.ListConversationsRequest): + request = contact_center_insights.ListConversationsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_conversations] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListConversationsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_conversation(self, + request: Optional[Union[contact_center_insights.DeleteConversationRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a conversation. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_delete_conversation(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteConversationRequest( + name="name_value", + ) + + # Make the request + client.delete_conversation(request=request) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeleteConversationRequest, dict]): + The request object. The request to delete a conversation. + name (str): + Required. The name of the + conversation to delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.DeleteConversationRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.DeleteConversationRequest): + request = contact_center_insights.DeleteConversationRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_conversation] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def create_analysis(self, + request: Optional[Union[contact_center_insights.CreateAnalysisRequest, dict]] = None, + *, + parent: Optional[str] = None, + analysis: Optional[resources.Analysis] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Creates an analysis. The long running operation is + done when the analysis has completed. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_create_analysis(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateAnalysisRequest( + parent="parent_value", + ) + + # Make the request + operation = client.create_analysis(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CreateAnalysisRequest, dict]): + The request object. The request to create an analysis. + parent (str): + Required. The parent resource of the + analysis. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + analysis (google.cloud.contact_center_insights_v1.types.Analysis): + Required. The analysis to create. + This corresponds to the ``analysis`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.Analysis` + The analysis resource. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, analysis]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.CreateAnalysisRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.CreateAnalysisRequest): + request = contact_center_insights.CreateAnalysisRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if analysis is not None: + request.analysis = analysis + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_analysis] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + resources.Analysis, + metadata_type=contact_center_insights.CreateAnalysisOperationMetadata, + ) + + # Done; return the response. + return response + + def get_analysis(self, + request: Optional[Union[contact_center_insights.GetAnalysisRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Analysis: + r"""Gets an analysis. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_get_analysis(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetAnalysisRequest( + name="name_value", + ) + + # Make the request + response = client.get_analysis(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetAnalysisRequest, dict]): + The request object. The request to get an analysis. + name (str): + Required. The name of the analysis to + get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Analysis: + The analysis resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.GetAnalysisRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.GetAnalysisRequest): + request = contact_center_insights.GetAnalysisRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_analysis] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_analyses(self, + request: Optional[Union[contact_center_insights.ListAnalysesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListAnalysesPager: + r"""Lists analyses. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_list_analyses(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListAnalysesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_analyses(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListAnalysesRequest, dict]): + The request object. The request to list analyses. + parent (str): + Required. The parent resource of the + analyses. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAnalysesPager: + The response to list analyses. + + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.ListAnalysesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.ListAnalysesRequest): + request = contact_center_insights.ListAnalysesRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_analyses] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListAnalysesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_analysis(self, + request: Optional[Union[contact_center_insights.DeleteAnalysisRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes an analysis. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_delete_analysis(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteAnalysisRequest( + name="name_value", + ) + + # Make the request + client.delete_analysis(request=request) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeleteAnalysisRequest, dict]): + The request object. The request to delete an analysis. + name (str): + Required. The name of the analysis to + delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.DeleteAnalysisRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.DeleteAnalysisRequest): + request = contact_center_insights.DeleteAnalysisRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_analysis] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def bulk_analyze_conversations(self, + request: Optional[Union[contact_center_insights.BulkAnalyzeConversationsRequest, dict]] = None, + *, + parent: Optional[str] = None, + filter: Optional[str] = None, + analysis_percentage: Optional[float] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Analyzes multiple conversations in a single request. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_bulk_analyze_conversations(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.BulkAnalyzeConversationsRequest( + parent="parent_value", + filter="filter_value", + analysis_percentage=0.20170000000000002, + ) + + # Make the request + operation = client.bulk_analyze_conversations(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.BulkAnalyzeConversationsRequest, dict]): + The request object. The request to analyze conversations + in bulk. + parent (str): + Required. The parent resource to + create analyses in. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + filter (str): + Required. Filter used to select the + subset of conversations to analyze. + + This corresponds to the ``filter`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + analysis_percentage (float): + Required. Percentage of selected conversation to + analyze, between [0, 100]. + + This corresponds to the ``analysis_percentage`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.BulkAnalyzeConversationsResponse` + The response for a bulk analyze conversations operation. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, filter, analysis_percentage]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.BulkAnalyzeConversationsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.BulkAnalyzeConversationsRequest): + request = contact_center_insights.BulkAnalyzeConversationsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if filter is not None: + request.filter = filter + if analysis_percentage is not None: + request.analysis_percentage = analysis_percentage + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.bulk_analyze_conversations] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + contact_center_insights.BulkAnalyzeConversationsResponse, + metadata_type=contact_center_insights.BulkAnalyzeConversationsMetadata, + ) + + # Done; return the response. + return response + + def ingest_conversations(self, + request: Optional[Union[contact_center_insights.IngestConversationsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Imports conversations and processes them according to + the user's configuration. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_ingest_conversations(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + gcs_source = contact_center_insights_v1.GcsSource() + gcs_source.bucket_uri = "bucket_uri_value" + + transcript_object_config = contact_center_insights_v1.TranscriptObjectConfig() + transcript_object_config.medium = "CHAT" + + request = contact_center_insights_v1.IngestConversationsRequest( + gcs_source=gcs_source, + transcript_object_config=transcript_object_config, + parent="parent_value", + ) + + # Make the request + operation = client.ingest_conversations(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.IngestConversationsRequest, dict]): + The request object. The request to ingest conversations. + parent (str): + Required. The parent resource for new + conversations. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.IngestConversationsResponse` + The response to an IngestConversations operation. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.IngestConversationsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.IngestConversationsRequest): + request = contact_center_insights.IngestConversationsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.ingest_conversations] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + contact_center_insights.IngestConversationsResponse, + metadata_type=contact_center_insights.IngestConversationsMetadata, + ) + + # Done; return the response. + return response + + def export_insights_data(self, + request: Optional[Union[contact_center_insights.ExportInsightsDataRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Export insights data to a destination defined in the + request body. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_export_insights_data(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + big_query_destination = contact_center_insights_v1.BigQueryDestination() + big_query_destination.dataset = "dataset_value" + + request = contact_center_insights_v1.ExportInsightsDataRequest( + big_query_destination=big_query_destination, + parent="parent_value", + ) + + # Make the request + operation = client.export_insights_data(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest, dict]): + The request object. The request to export insights. + parent (str): + Required. The parent resource to + export data from. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.ExportInsightsDataResponse` + Response for an export insights operation. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.ExportInsightsDataRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.ExportInsightsDataRequest): + request = contact_center_insights.ExportInsightsDataRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.export_insights_data] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + contact_center_insights.ExportInsightsDataResponse, + metadata_type=contact_center_insights.ExportInsightsDataMetadata, + ) + + # Done; return the response. + return response + + def create_issue_model(self, + request: Optional[Union[contact_center_insights.CreateIssueModelRequest, dict]] = None, + *, + parent: Optional[str] = None, + issue_model: Optional[resources.IssueModel] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Creates an issue model. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_create_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateIssueModelRequest( + parent="parent_value", + ) + + # Make the request + operation = client.create_issue_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CreateIssueModelRequest, dict]): + The request object. The request to create an issue model. + parent (str): + Required. The parent resource of the + issue model. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + issue_model (google.cloud.contact_center_insights_v1.types.IssueModel): + Required. The issue model to create. + This corresponds to the ``issue_model`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.IssueModel` + The issue model resource. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, issue_model]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.CreateIssueModelRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.CreateIssueModelRequest): + request = contact_center_insights.CreateIssueModelRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if issue_model is not None: + request.issue_model = issue_model + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_issue_model] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + resources.IssueModel, + metadata_type=contact_center_insights.CreateIssueModelMetadata, + ) + + # Done; return the response. + return response + + def update_issue_model(self, + request: Optional[Union[contact_center_insights.UpdateIssueModelRequest, dict]] = None, + *, + issue_model: Optional[resources.IssueModel] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.IssueModel: + r"""Updates an issue model. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_update_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateIssueModelRequest( + ) + + # Make the request + response = client.update_issue_model(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdateIssueModelRequest, dict]): + The request object. The request to update an issue model. + issue_model (google.cloud.contact_center_insights_v1.types.IssueModel): + Required. The new values for the + issue model. + + This corresponds to the ``issue_model`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.IssueModel: + The issue model resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([issue_model, update_mask]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.UpdateIssueModelRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.UpdateIssueModelRequest): + request = contact_center_insights.UpdateIssueModelRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if issue_model is not None: + request.issue_model = issue_model + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_issue_model] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("issue_model.name", request.issue_model.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_issue_model(self, + request: Optional[Union[contact_center_insights.GetIssueModelRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.IssueModel: + r"""Gets an issue model. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_get_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetIssueModelRequest( + name="name_value", + ) + + # Make the request + response = client.get_issue_model(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetIssueModelRequest, dict]): + The request object. The request to get an issue model. + name (str): + Required. The name of the issue model + to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.IssueModel: + The issue model resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.GetIssueModelRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.GetIssueModelRequest): + request = contact_center_insights.GetIssueModelRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_issue_model] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_issue_models(self, + request: Optional[Union[contact_center_insights.ListIssueModelsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> contact_center_insights.ListIssueModelsResponse: + r"""Lists issue models. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_list_issue_models(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListIssueModelsRequest( + parent="parent_value", + ) + + # Make the request + response = client.list_issue_models(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListIssueModelsRequest, dict]): + The request object. Request to list issue models. + parent (str): + Required. The parent resource of the + issue model. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.ListIssueModelsResponse: + The response of listing issue models. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.ListIssueModelsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.ListIssueModelsRequest): + request = contact_center_insights.ListIssueModelsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_issue_models] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_issue_model(self, + request: Optional[Union[contact_center_insights.DeleteIssueModelRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Deletes an issue model. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_delete_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteIssueModelRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_issue_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeleteIssueModelRequest, dict]): + The request object. The request to delete an issue model. + name (str): + Required. The name of the issue model + to delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.DeleteIssueModelRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.DeleteIssueModelRequest): + request = contact_center_insights.DeleteIssueModelRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_issue_model] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + empty_pb2.Empty, + metadata_type=contact_center_insights.DeleteIssueModelMetadata, + ) + + # Done; return the response. + return response + + def deploy_issue_model(self, + request: Optional[Union[contact_center_insights.DeployIssueModelRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Deploys an issue model. Returns an error if a model + is already deployed. An issue model can only be used in + analysis after it has been deployed. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_deploy_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeployIssueModelRequest( + name="name_value", + ) + + # Make the request + operation = client.deploy_issue_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeployIssueModelRequest, dict]): + The request object. The request to deploy an issue model. + name (str): + Required. The issue model to deploy. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.DeployIssueModelResponse` + The response to deploy an issue model. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.DeployIssueModelRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.DeployIssueModelRequest): + request = contact_center_insights.DeployIssueModelRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.deploy_issue_model] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + contact_center_insights.DeployIssueModelResponse, + metadata_type=contact_center_insights.DeployIssueModelMetadata, + ) + + # Done; return the response. + return response + + def undeploy_issue_model(self, + request: Optional[Union[contact_center_insights.UndeployIssueModelRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Undeploys an issue model. + An issue model can not be used in analysis after it has + been undeployed. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_undeploy_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UndeployIssueModelRequest( + name="name_value", + ) + + # Make the request + operation = client.undeploy_issue_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UndeployIssueModelRequest, dict]): + The request object. The request to undeploy an issue + model. + name (str): + Required. The issue model to + undeploy. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.contact_center_insights_v1.types.UndeployIssueModelResponse` + The response to undeploy an issue model. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.UndeployIssueModelRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.UndeployIssueModelRequest): + request = contact_center_insights.UndeployIssueModelRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.undeploy_issue_model] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + contact_center_insights.UndeployIssueModelResponse, + metadata_type=contact_center_insights.UndeployIssueModelMetadata, + ) + + # Done; return the response. + return response + + def get_issue(self, + request: Optional[Union[contact_center_insights.GetIssueRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Issue: + r"""Gets an issue. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_get_issue(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetIssueRequest( + name="name_value", + ) + + # Make the request + response = client.get_issue(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetIssueRequest, dict]): + The request object. The request to get an issue. + name (str): + Required. The name of the issue to + get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Issue: + The issue resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.GetIssueRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.GetIssueRequest): + request = contact_center_insights.GetIssueRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_issue] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_issues(self, + request: Optional[Union[contact_center_insights.ListIssuesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> contact_center_insights.ListIssuesResponse: + r"""Lists issues. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_list_issues(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListIssuesRequest( + parent="parent_value", + ) + + # Make the request + response = client.list_issues(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListIssuesRequest, dict]): + The request object. Request to list issues. + parent (str): + Required. The parent resource of the + issue. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.ListIssuesResponse: + The response of listing issues. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.ListIssuesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.ListIssuesRequest): + request = contact_center_insights.ListIssuesRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_issues] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_issue(self, + request: Optional[Union[contact_center_insights.UpdateIssueRequest, dict]] = None, + *, + issue: Optional[resources.Issue] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Issue: + r"""Updates an issue. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_update_issue(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateIssueRequest( + ) + + # Make the request + response = client.update_issue(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdateIssueRequest, dict]): + The request object. The request to update an issue. + issue (google.cloud.contact_center_insights_v1.types.Issue): + Required. The new values for the + issue. + + This corresponds to the ``issue`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Issue: + The issue resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([issue, update_mask]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.UpdateIssueRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.UpdateIssueRequest): + request = contact_center_insights.UpdateIssueRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if issue is not None: + request.issue = issue + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_issue] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("issue.name", request.issue.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_issue(self, + request: Optional[Union[contact_center_insights.DeleteIssueRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes an issue. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_delete_issue(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteIssueRequest( + name="name_value", + ) + + # Make the request + client.delete_issue(request=request) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeleteIssueRequest, dict]): + The request object. The request to delete an issue. + name (str): + Required. The name of the issue to + delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.DeleteIssueRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.DeleteIssueRequest): + request = contact_center_insights.DeleteIssueRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_issue] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def calculate_issue_model_stats(self, + request: Optional[Union[contact_center_insights.CalculateIssueModelStatsRequest, dict]] = None, + *, + issue_model: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> contact_center_insights.CalculateIssueModelStatsResponse: + r"""Gets an issue model's statistics. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_calculate_issue_model_stats(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CalculateIssueModelStatsRequest( + issue_model="issue_model_value", + ) + + # Make the request + response = client.calculate_issue_model_stats(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsRequest, dict]): + The request object. Request to get statistics of an issue + model. + issue_model (str): + Required. The resource name of the + issue model to query against. + + This corresponds to the ``issue_model`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsResponse: + Response of querying an issue model's + statistics. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([issue_model]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.CalculateIssueModelStatsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.CalculateIssueModelStatsRequest): + request = contact_center_insights.CalculateIssueModelStatsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if issue_model is not None: + request.issue_model = issue_model + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.calculate_issue_model_stats] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("issue_model", request.issue_model), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_phrase_matcher(self, + request: Optional[Union[contact_center_insights.CreatePhraseMatcherRequest, dict]] = None, + *, + parent: Optional[str] = None, + phrase_matcher: Optional[resources.PhraseMatcher] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.PhraseMatcher: + r"""Creates a phrase matcher. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_create_phrase_matcher(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + phrase_matcher = contact_center_insights_v1.PhraseMatcher() + phrase_matcher.type_ = "ANY_OF" + + request = contact_center_insights_v1.CreatePhraseMatcherRequest( + parent="parent_value", + phrase_matcher=phrase_matcher, + ) + + # Make the request + response = client.create_phrase_matcher(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CreatePhraseMatcherRequest, dict]): + The request object. Request to create a phrase matcher. + parent (str): + Required. The parent resource of the phrase matcher. + Required. The location to create a phrase matcher for. + Format: + ``projects//locations/`` or + ``projects//locations/`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + phrase_matcher (google.cloud.contact_center_insights_v1.types.PhraseMatcher): + Required. The phrase matcher resource + to create. + + This corresponds to the ``phrase_matcher`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.PhraseMatcher: + The phrase matcher resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, phrase_matcher]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.CreatePhraseMatcherRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.CreatePhraseMatcherRequest): + request = contact_center_insights.CreatePhraseMatcherRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if phrase_matcher is not None: + request.phrase_matcher = phrase_matcher + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_phrase_matcher] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_phrase_matcher(self, + request: Optional[Union[contact_center_insights.GetPhraseMatcherRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.PhraseMatcher: + r"""Gets a phrase matcher. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_get_phrase_matcher(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetPhraseMatcherRequest( + name="name_value", + ) + + # Make the request + response = client.get_phrase_matcher(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetPhraseMatcherRequest, dict]): + The request object. The request to get a a phrase + matcher. + name (str): + Required. The name of the phrase + matcher to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.PhraseMatcher: + The phrase matcher resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.GetPhraseMatcherRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.GetPhraseMatcherRequest): + request = contact_center_insights.GetPhraseMatcherRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_phrase_matcher] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_phrase_matchers(self, + request: Optional[Union[contact_center_insights.ListPhraseMatchersRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListPhraseMatchersPager: + r"""Lists phrase matchers. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_list_phrase_matchers(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListPhraseMatchersRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_phrase_matchers(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListPhraseMatchersRequest, dict]): + The request object. Request to list phrase matchers. + parent (str): + Required. The parent resource of the + phrase matcher. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListPhraseMatchersPager: + The response of listing phrase + matchers. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.ListPhraseMatchersRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.ListPhraseMatchersRequest): + request = contact_center_insights.ListPhraseMatchersRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_phrase_matchers] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListPhraseMatchersPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_phrase_matcher(self, + request: Optional[Union[contact_center_insights.DeletePhraseMatcherRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a phrase matcher. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_delete_phrase_matcher(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeletePhraseMatcherRequest( + name="name_value", + ) + + # Make the request + client.delete_phrase_matcher(request=request) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeletePhraseMatcherRequest, dict]): + The request object. The request to delete a phrase + matcher. + name (str): + Required. The name of the phrase + matcher to delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.DeletePhraseMatcherRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.DeletePhraseMatcherRequest): + request = contact_center_insights.DeletePhraseMatcherRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_phrase_matcher] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def update_phrase_matcher(self, + request: Optional[Union[contact_center_insights.UpdatePhraseMatcherRequest, dict]] = None, + *, + phrase_matcher: Optional[resources.PhraseMatcher] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.PhraseMatcher: + r"""Updates a phrase matcher. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_update_phrase_matcher(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + phrase_matcher = contact_center_insights_v1.PhraseMatcher() + phrase_matcher.type_ = "ANY_OF" + + request = contact_center_insights_v1.UpdatePhraseMatcherRequest( + phrase_matcher=phrase_matcher, + ) + + # Make the request + response = client.update_phrase_matcher(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdatePhraseMatcherRequest, dict]): + The request object. The request to update a phrase + matcher. + phrase_matcher (google.cloud.contact_center_insights_v1.types.PhraseMatcher): + Required. The new values for the + phrase matcher. + + This corresponds to the ``phrase_matcher`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.PhraseMatcher: + The phrase matcher resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([phrase_matcher, update_mask]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.UpdatePhraseMatcherRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.UpdatePhraseMatcherRequest): + request = contact_center_insights.UpdatePhraseMatcherRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if phrase_matcher is not None: + request.phrase_matcher = phrase_matcher + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_phrase_matcher] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("phrase_matcher.name", request.phrase_matcher.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def calculate_stats(self, + request: Optional[Union[contact_center_insights.CalculateStatsRequest, dict]] = None, + *, + location: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> contact_center_insights.CalculateStatsResponse: + r"""Gets conversation statistics. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_calculate_stats(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CalculateStatsRequest( + location="location_value", + ) + + # Make the request + response = client.calculate_stats(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CalculateStatsRequest, dict]): + The request object. The request for calculating + conversation statistics. + location (str): + Required. The location of the + conversations. + + This corresponds to the ``location`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.CalculateStatsResponse: + The response for calculating + conversation statistics. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([location]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.CalculateStatsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.CalculateStatsRequest): + request = contact_center_insights.CalculateStatsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if location is not None: + request.location = location + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.calculate_stats] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("location", request.location), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_settings(self, + request: Optional[Union[contact_center_insights.GetSettingsRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Settings: + r"""Gets project-level settings. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_get_settings(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetSettingsRequest( + name="name_value", + ) + + # Make the request + response = client.get_settings(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetSettingsRequest, dict]): + The request object. The request to get project-level + settings. + name (str): + Required. The name of the settings + resource to get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Settings: + The settings resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.GetSettingsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.GetSettingsRequest): + request = contact_center_insights.GetSettingsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_settings] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_settings(self, + request: Optional[Union[contact_center_insights.UpdateSettingsRequest, dict]] = None, + *, + settings: Optional[resources.Settings] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Settings: + r"""Updates project-level settings. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_update_settings(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateSettingsRequest( + ) + + # Make the request + response = client.update_settings(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdateSettingsRequest, dict]): + The request object. The request to update project-level + settings. + settings (google.cloud.contact_center_insights_v1.types.Settings): + Required. The new settings values. + This corresponds to the ``settings`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be + updated. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.Settings: + The settings resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([settings, update_mask]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.UpdateSettingsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.UpdateSettingsRequest): + request = contact_center_insights.UpdateSettingsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if settings is not None: + request.settings = settings + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_settings] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("settings.name", request.settings.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_view(self, + request: Optional[Union[contact_center_insights.CreateViewRequest, dict]] = None, + *, + parent: Optional[str] = None, + view: Optional[resources.View] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.View: + r"""Creates a view. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_create_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateViewRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_view(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.CreateViewRequest, dict]): + The request object. The request to create a view. + parent (str): + Required. The parent resource of the view. Required. The + location to create a view for. Format: + ``projects//locations/`` or + ``projects//locations/`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + view (google.cloud.contact_center_insights_v1.types.View): + Required. The view resource to + create. + + This corresponds to the ``view`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.View: + The View resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, view]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.CreateViewRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.CreateViewRequest): + request = contact_center_insights.CreateViewRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if view is not None: + request.view = view + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_view] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_view(self, + request: Optional[Union[contact_center_insights.GetViewRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.View: + r"""Gets a view. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_get_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetViewRequest( + name="name_value", + ) + + # Make the request + response = client.get_view(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.GetViewRequest, dict]): + The request object. The request to get a view. + name (str): + Required. The name of the view to + get. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.View: + The View resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.GetViewRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.GetViewRequest): + request = contact_center_insights.GetViewRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_view] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_views(self, + request: Optional[Union[contact_center_insights.ListViewsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListViewsPager: + r"""Lists views. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_list_views(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListViewsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_views(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.ListViewsRequest, dict]): + The request object. The request to list views. + parent (str): + Required. The parent resource of the + views. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListViewsPager: + The response of listing views. + + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.ListViewsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.ListViewsRequest): + request = contact_center_insights.ListViewsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_views] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("parent", request.parent), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListViewsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_view(self, + request: Optional[Union[contact_center_insights.UpdateViewRequest, dict]] = None, + *, + view: Optional[resources.View] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.View: + r"""Updates a view. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_update_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateViewRequest( + ) + + # Make the request + response = client.update_view(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.UpdateViewRequest, dict]): + The request object. The request to update a view. + view (google.cloud.contact_center_insights_v1.types.View): + Required. The new view. + This corresponds to the ``view`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.contact_center_insights_v1.types.View: + The View resource. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([view, update_mask]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.UpdateViewRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.UpdateViewRequest): + request = contact_center_insights.UpdateViewRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if view is not None: + request.view = view + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_view] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("view.name", request.view.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_view(self, + request: Optional[Union[contact_center_insights.DeleteViewRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a view. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import contact_center_insights_v1 + + def sample_delete_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteViewRequest( + name="name_value", + ) + + # Make the request + client.delete_view(request=request) + + Args: + request (Union[google.cloud.contact_center_insights_v1.types.DeleteViewRequest, dict]): + The request object. The request to delete a view. + name (str): + Required. The name of the view to + delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.DeleteViewRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, contact_center_insights.DeleteViewRequest): + request = contact_center_insights.DeleteViewRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_view] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def __enter__(self) -> "ContactCenterInsightsClient": + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + + def list_operations( + self, + request: Optional[operations_pb2.ListOperationsRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.ListOperationsResponse: + r"""Lists operations that match the specified filter in the request. + + Args: + request (:class:`~.operations_pb2.ListOperationsRequest`): + The request object. Request message for + `ListOperations` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + ~.operations_pb2.ListOperationsResponse: + Response message for ``ListOperations`` method. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.ListOperationsRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.list_operations, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def get_operation( + self, + request: Optional[operations_pb2.GetOperationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Gets the latest state of a long-running operation. + + Args: + request (:class:`~.operations_pb2.GetOperationRequest`): + The request object. Request message for + `GetOperation` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + ~.operations_pb2.Operation: + An ``Operation`` object. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.GetOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.get_operation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def cancel_operation( + self, + request: Optional[operations_pb2.CancelOperationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Starts asynchronous cancellation on a long-running operation. + + The server makes a best effort to cancel the operation, but success + is not guaranteed. If the server doesn't support this method, it returns + `google.rpc.Code.UNIMPLEMENTED`. + + Args: + request (:class:`~.operations_pb2.CancelOperationRequest`): + The request object. Request message for + `CancelOperation` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + None + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = operations_pb2.CancelOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.cancel_operation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("name", request.name),)), + ) + + # Send the request. + rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + + + + + + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) + + +__all__ = ( + "ContactCenterInsightsClient", +) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/pagers.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/pagers.py new file mode 100644 index 000000000000..d72bcf95cbe6 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/pagers.py @@ -0,0 +1,503 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +from typing import Any, AsyncIterator, Awaitable, Callable, Sequence, Tuple, Optional, Iterator + +from google.cloud.contact_center_insights_v1.types import contact_center_insights +from google.cloud.contact_center_insights_v1.types import resources + + +class ListConversationsPager: + """A pager for iterating through ``list_conversations`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListConversationsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``conversations`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListConversations`` requests and continue to iterate + through the ``conversations`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListConversationsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., contact_center_insights.ListConversationsResponse], + request: contact_center_insights.ListConversationsRequest, + response: contact_center_insights.ListConversationsResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.contact_center_insights_v1.types.ListConversationsRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListConversationsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = contact_center_insights.ListConversationsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[contact_center_insights.ListConversationsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[resources.Conversation]: + for page in self.pages: + yield from page.conversations + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListConversationsAsyncPager: + """A pager for iterating through ``list_conversations`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListConversationsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``conversations`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListConversations`` requests and continue to iterate + through the ``conversations`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListConversationsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., Awaitable[contact_center_insights.ListConversationsResponse]], + request: contact_center_insights.ListConversationsRequest, + response: contact_center_insights.ListConversationsResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.contact_center_insights_v1.types.ListConversationsRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListConversationsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = contact_center_insights.ListConversationsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[contact_center_insights.ListConversationsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + def __aiter__(self) -> AsyncIterator[resources.Conversation]: + async def async_generator(): + async for page in self.pages: + for response in page.conversations: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListAnalysesPager: + """A pager for iterating through ``list_analyses`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListAnalysesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``analyses`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListAnalyses`` requests and continue to iterate + through the ``analyses`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListAnalysesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., contact_center_insights.ListAnalysesResponse], + request: contact_center_insights.ListAnalysesRequest, + response: contact_center_insights.ListAnalysesResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.contact_center_insights_v1.types.ListAnalysesRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListAnalysesResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = contact_center_insights.ListAnalysesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[contact_center_insights.ListAnalysesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[resources.Analysis]: + for page in self.pages: + yield from page.analyses + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListAnalysesAsyncPager: + """A pager for iterating through ``list_analyses`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListAnalysesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``analyses`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListAnalyses`` requests and continue to iterate + through the ``analyses`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListAnalysesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., Awaitable[contact_center_insights.ListAnalysesResponse]], + request: contact_center_insights.ListAnalysesRequest, + response: contact_center_insights.ListAnalysesResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.contact_center_insights_v1.types.ListAnalysesRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListAnalysesResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = contact_center_insights.ListAnalysesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[contact_center_insights.ListAnalysesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + def __aiter__(self) -> AsyncIterator[resources.Analysis]: + async def async_generator(): + async for page in self.pages: + for response in page.analyses: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListPhraseMatchersPager: + """A pager for iterating through ``list_phrase_matchers`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListPhraseMatchersResponse` object, and + provides an ``__iter__`` method to iterate through its + ``phrase_matchers`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListPhraseMatchers`` requests and continue to iterate + through the ``phrase_matchers`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListPhraseMatchersResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., contact_center_insights.ListPhraseMatchersResponse], + request: contact_center_insights.ListPhraseMatchersRequest, + response: contact_center_insights.ListPhraseMatchersResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.contact_center_insights_v1.types.ListPhraseMatchersRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListPhraseMatchersResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = contact_center_insights.ListPhraseMatchersRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[contact_center_insights.ListPhraseMatchersResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[resources.PhraseMatcher]: + for page in self.pages: + yield from page.phrase_matchers + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListPhraseMatchersAsyncPager: + """A pager for iterating through ``list_phrase_matchers`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListPhraseMatchersResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``phrase_matchers`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListPhraseMatchers`` requests and continue to iterate + through the ``phrase_matchers`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListPhraseMatchersResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., Awaitable[contact_center_insights.ListPhraseMatchersResponse]], + request: contact_center_insights.ListPhraseMatchersRequest, + response: contact_center_insights.ListPhraseMatchersResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.contact_center_insights_v1.types.ListPhraseMatchersRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListPhraseMatchersResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = contact_center_insights.ListPhraseMatchersRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[contact_center_insights.ListPhraseMatchersResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + def __aiter__(self) -> AsyncIterator[resources.PhraseMatcher]: + async def async_generator(): + async for page in self.pages: + for response in page.phrase_matchers: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListViewsPager: + """A pager for iterating through ``list_views`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListViewsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``views`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListViews`` requests and continue to iterate + through the ``views`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListViewsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., contact_center_insights.ListViewsResponse], + request: contact_center_insights.ListViewsRequest, + response: contact_center_insights.ListViewsResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.contact_center_insights_v1.types.ListViewsRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListViewsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = contact_center_insights.ListViewsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[contact_center_insights.ListViewsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[resources.View]: + for page in self.pages: + yield from page.views + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListViewsAsyncPager: + """A pager for iterating through ``list_views`` requests. + + This class thinly wraps an initial + :class:`google.cloud.contact_center_insights_v1.types.ListViewsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``views`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListViews`` requests and continue to iterate + through the ``views`` field on the + corresponding responses. + + All the usual :class:`google.cloud.contact_center_insights_v1.types.ListViewsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + def __init__(self, + method: Callable[..., Awaitable[contact_center_insights.ListViewsResponse]], + request: contact_center_insights.ListViewsRequest, + response: contact_center_insights.ListViewsResponse, + *, + metadata: Sequence[Tuple[str, str]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.contact_center_insights_v1.types.ListViewsRequest): + The initial request object. + response (google.cloud.contact_center_insights_v1.types.ListViewsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = contact_center_insights.ListViewsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[contact_center_insights.ListViewsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + def __aiter__(self) -> AsyncIterator[resources.View]: + async def async_generator(): + async for page in self.pages: + for response in page.views: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/__init__.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/__init__.py new file mode 100644 index 000000000000..a8cfa0a8c705 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/__init__.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +from collections import OrderedDict +from typing import Dict, Type + +from .base import ContactCenterInsightsTransport +from .grpc import ContactCenterInsightsGrpcTransport +from .grpc_asyncio import ContactCenterInsightsGrpcAsyncIOTransport +from .rest import ContactCenterInsightsRestTransport +from .rest import ContactCenterInsightsRestInterceptor + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[ContactCenterInsightsTransport]] +_transport_registry['grpc'] = ContactCenterInsightsGrpcTransport +_transport_registry['grpc_asyncio'] = ContactCenterInsightsGrpcAsyncIOTransport +_transport_registry['rest'] = ContactCenterInsightsRestTransport + +__all__ = ( + 'ContactCenterInsightsTransport', + 'ContactCenterInsightsGrpcTransport', + 'ContactCenterInsightsGrpcAsyncIOTransport', + 'ContactCenterInsightsRestTransport', + 'ContactCenterInsightsRestInterceptor', +) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py new file mode 100644 index 000000000000..7a1631aa7fec --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py @@ -0,0 +1,702 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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 abc +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union + +from google.cloud.contact_center_insights_v1 import gapic_version as package_version + +import google.auth # type: ignore +import google.api_core +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +from google.api_core import operations_v1 +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.contact_center_insights_v1.types import contact_center_insights +from google.cloud.contact_center_insights_v1.types import resources +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) + + +class ContactCenterInsightsTransport(abc.ABC): + """Abstract transport class for ContactCenterInsights.""" + + AUTH_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + ) + + DEFAULT_HOST: str = 'contactcenterinsights.googleapis.com' + def __init__( + self, *, + host: str = DEFAULT_HOST, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, + **kwargs, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A list of scopes. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + """ + + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} + + # Save the scopes. + self._scopes = scopes + + # If no credentials are provided, then determine the appropriate + # defaults. + if credentials and credentials_file: + raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") + + if credentials_file is not None: + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, + **scopes_kwargs, + quota_project_id=quota_project_id + ) + elif credentials is None: + credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) + # Don't apply audience if the credentials file passed from user. + if hasattr(credentials, "with_gdch_audience"): + credentials = credentials.with_gdch_audience(api_audience if api_audience else host) + + # If the credentials are service account credentials, then always try to use self signed JWT. + if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): + credentials = credentials.with_always_use_jwt_access(True) + + # Save the credentials. + self._credentials = credentials + + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ':' not in host: + host += ':443' + self._host = host + + def _prep_wrapped_messages(self, client_info): + # Precompute the wrapped methods. + self._wrapped_methods = { + self.create_conversation: gapic_v1.method.wrap_method( + self.create_conversation, + default_timeout=None, + client_info=client_info, + ), + self.upload_conversation: gapic_v1.method.wrap_method( + self.upload_conversation, + default_timeout=None, + client_info=client_info, + ), + self.update_conversation: gapic_v1.method.wrap_method( + self.update_conversation, + default_timeout=None, + client_info=client_info, + ), + self.get_conversation: gapic_v1.method.wrap_method( + self.get_conversation, + default_timeout=None, + client_info=client_info, + ), + self.list_conversations: gapic_v1.method.wrap_method( + self.list_conversations, + default_timeout=None, + client_info=client_info, + ), + self.delete_conversation: gapic_v1.method.wrap_method( + self.delete_conversation, + default_timeout=None, + client_info=client_info, + ), + self.create_analysis: gapic_v1.method.wrap_method( + self.create_analysis, + default_timeout=None, + client_info=client_info, + ), + self.get_analysis: gapic_v1.method.wrap_method( + self.get_analysis, + default_timeout=None, + client_info=client_info, + ), + self.list_analyses: gapic_v1.method.wrap_method( + self.list_analyses, + default_timeout=None, + client_info=client_info, + ), + self.delete_analysis: gapic_v1.method.wrap_method( + self.delete_analysis, + default_timeout=None, + client_info=client_info, + ), + self.bulk_analyze_conversations: gapic_v1.method.wrap_method( + self.bulk_analyze_conversations, + default_timeout=None, + client_info=client_info, + ), + self.ingest_conversations: gapic_v1.method.wrap_method( + self.ingest_conversations, + default_timeout=None, + client_info=client_info, + ), + self.export_insights_data: gapic_v1.method.wrap_method( + self.export_insights_data, + default_timeout=None, + client_info=client_info, + ), + self.create_issue_model: gapic_v1.method.wrap_method( + self.create_issue_model, + default_timeout=None, + client_info=client_info, + ), + self.update_issue_model: gapic_v1.method.wrap_method( + self.update_issue_model, + default_timeout=None, + client_info=client_info, + ), + self.get_issue_model: gapic_v1.method.wrap_method( + self.get_issue_model, + default_timeout=None, + client_info=client_info, + ), + self.list_issue_models: gapic_v1.method.wrap_method( + self.list_issue_models, + default_timeout=None, + client_info=client_info, + ), + self.delete_issue_model: gapic_v1.method.wrap_method( + self.delete_issue_model, + default_timeout=None, + client_info=client_info, + ), + self.deploy_issue_model: gapic_v1.method.wrap_method( + self.deploy_issue_model, + default_timeout=None, + client_info=client_info, + ), + self.undeploy_issue_model: gapic_v1.method.wrap_method( + self.undeploy_issue_model, + default_timeout=None, + client_info=client_info, + ), + self.get_issue: gapic_v1.method.wrap_method( + self.get_issue, + default_timeout=None, + client_info=client_info, + ), + self.list_issues: gapic_v1.method.wrap_method( + self.list_issues, + default_timeout=None, + client_info=client_info, + ), + self.update_issue: gapic_v1.method.wrap_method( + self.update_issue, + default_timeout=None, + client_info=client_info, + ), + self.delete_issue: gapic_v1.method.wrap_method( + self.delete_issue, + default_timeout=None, + client_info=client_info, + ), + self.calculate_issue_model_stats: gapic_v1.method.wrap_method( + self.calculate_issue_model_stats, + default_timeout=None, + client_info=client_info, + ), + self.create_phrase_matcher: gapic_v1.method.wrap_method( + self.create_phrase_matcher, + default_timeout=None, + client_info=client_info, + ), + self.get_phrase_matcher: gapic_v1.method.wrap_method( + self.get_phrase_matcher, + default_timeout=None, + client_info=client_info, + ), + self.list_phrase_matchers: gapic_v1.method.wrap_method( + self.list_phrase_matchers, + default_timeout=None, + client_info=client_info, + ), + self.delete_phrase_matcher: gapic_v1.method.wrap_method( + self.delete_phrase_matcher, + default_timeout=None, + client_info=client_info, + ), + self.update_phrase_matcher: gapic_v1.method.wrap_method( + self.update_phrase_matcher, + default_timeout=None, + client_info=client_info, + ), + self.calculate_stats: gapic_v1.method.wrap_method( + self.calculate_stats, + default_timeout=None, + client_info=client_info, + ), + self.get_settings: gapic_v1.method.wrap_method( + self.get_settings, + default_timeout=None, + client_info=client_info, + ), + self.update_settings: gapic_v1.method.wrap_method( + self.update_settings, + default_timeout=None, + client_info=client_info, + ), + self.create_view: gapic_v1.method.wrap_method( + self.create_view, + default_timeout=None, + client_info=client_info, + ), + self.get_view: gapic_v1.method.wrap_method( + self.get_view, + default_timeout=None, + client_info=client_info, + ), + self.list_views: gapic_v1.method.wrap_method( + self.list_views, + default_timeout=None, + client_info=client_info, + ), + self.update_view: gapic_v1.method.wrap_method( + self.update_view, + default_timeout=None, + client_info=client_info, + ), + self.delete_view: gapic_v1.method.wrap_method( + self.delete_view, + default_timeout=None, + client_info=client_info, + ), + } + + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + + @property + def operations_client(self): + """Return the client designed to process long-running operations.""" + raise NotImplementedError() + + @property + def create_conversation(self) -> Callable[ + [contact_center_insights.CreateConversationRequest], + Union[ + resources.Conversation, + Awaitable[resources.Conversation] + ]]: + raise NotImplementedError() + + @property + def upload_conversation(self) -> Callable[ + [contact_center_insights.UploadConversationRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_conversation(self) -> Callable[ + [contact_center_insights.UpdateConversationRequest], + Union[ + resources.Conversation, + Awaitable[resources.Conversation] + ]]: + raise NotImplementedError() + + @property + def get_conversation(self) -> Callable[ + [contact_center_insights.GetConversationRequest], + Union[ + resources.Conversation, + Awaitable[resources.Conversation] + ]]: + raise NotImplementedError() + + @property + def list_conversations(self) -> Callable[ + [contact_center_insights.ListConversationsRequest], + Union[ + contact_center_insights.ListConversationsResponse, + Awaitable[contact_center_insights.ListConversationsResponse] + ]]: + raise NotImplementedError() + + @property + def delete_conversation(self) -> Callable[ + [contact_center_insights.DeleteConversationRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def create_analysis(self) -> Callable[ + [contact_center_insights.CreateAnalysisRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def get_analysis(self) -> Callable[ + [contact_center_insights.GetAnalysisRequest], + Union[ + resources.Analysis, + Awaitable[resources.Analysis] + ]]: + raise NotImplementedError() + + @property + def list_analyses(self) -> Callable[ + [contact_center_insights.ListAnalysesRequest], + Union[ + contact_center_insights.ListAnalysesResponse, + Awaitable[contact_center_insights.ListAnalysesResponse] + ]]: + raise NotImplementedError() + + @property + def delete_analysis(self) -> Callable[ + [contact_center_insights.DeleteAnalysisRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def bulk_analyze_conversations(self) -> Callable[ + [contact_center_insights.BulkAnalyzeConversationsRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def ingest_conversations(self) -> Callable[ + [contact_center_insights.IngestConversationsRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def export_insights_data(self) -> Callable[ + [contact_center_insights.ExportInsightsDataRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def create_issue_model(self) -> Callable[ + [contact_center_insights.CreateIssueModelRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_issue_model(self) -> Callable[ + [contact_center_insights.UpdateIssueModelRequest], + Union[ + resources.IssueModel, + Awaitable[resources.IssueModel] + ]]: + raise NotImplementedError() + + @property + def get_issue_model(self) -> Callable[ + [contact_center_insights.GetIssueModelRequest], + Union[ + resources.IssueModel, + Awaitable[resources.IssueModel] + ]]: + raise NotImplementedError() + + @property + def list_issue_models(self) -> Callable[ + [contact_center_insights.ListIssueModelsRequest], + Union[ + contact_center_insights.ListIssueModelsResponse, + Awaitable[contact_center_insights.ListIssueModelsResponse] + ]]: + raise NotImplementedError() + + @property + def delete_issue_model(self) -> Callable[ + [contact_center_insights.DeleteIssueModelRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def deploy_issue_model(self) -> Callable[ + [contact_center_insights.DeployIssueModelRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def undeploy_issue_model(self) -> Callable[ + [contact_center_insights.UndeployIssueModelRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def get_issue(self) -> Callable[ + [contact_center_insights.GetIssueRequest], + Union[ + resources.Issue, + Awaitable[resources.Issue] + ]]: + raise NotImplementedError() + + @property + def list_issues(self) -> Callable[ + [contact_center_insights.ListIssuesRequest], + Union[ + contact_center_insights.ListIssuesResponse, + Awaitable[contact_center_insights.ListIssuesResponse] + ]]: + raise NotImplementedError() + + @property + def update_issue(self) -> Callable[ + [contact_center_insights.UpdateIssueRequest], + Union[ + resources.Issue, + Awaitable[resources.Issue] + ]]: + raise NotImplementedError() + + @property + def delete_issue(self) -> Callable[ + [contact_center_insights.DeleteIssueRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def calculate_issue_model_stats(self) -> Callable[ + [contact_center_insights.CalculateIssueModelStatsRequest], + Union[ + contact_center_insights.CalculateIssueModelStatsResponse, + Awaitable[contact_center_insights.CalculateIssueModelStatsResponse] + ]]: + raise NotImplementedError() + + @property + def create_phrase_matcher(self) -> Callable[ + [contact_center_insights.CreatePhraseMatcherRequest], + Union[ + resources.PhraseMatcher, + Awaitable[resources.PhraseMatcher] + ]]: + raise NotImplementedError() + + @property + def get_phrase_matcher(self) -> Callable[ + [contact_center_insights.GetPhraseMatcherRequest], + Union[ + resources.PhraseMatcher, + Awaitable[resources.PhraseMatcher] + ]]: + raise NotImplementedError() + + @property + def list_phrase_matchers(self) -> Callable[ + [contact_center_insights.ListPhraseMatchersRequest], + Union[ + contact_center_insights.ListPhraseMatchersResponse, + Awaitable[contact_center_insights.ListPhraseMatchersResponse] + ]]: + raise NotImplementedError() + + @property + def delete_phrase_matcher(self) -> Callable[ + [contact_center_insights.DeletePhraseMatcherRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def update_phrase_matcher(self) -> Callable[ + [contact_center_insights.UpdatePhraseMatcherRequest], + Union[ + resources.PhraseMatcher, + Awaitable[resources.PhraseMatcher] + ]]: + raise NotImplementedError() + + @property + def calculate_stats(self) -> Callable[ + [contact_center_insights.CalculateStatsRequest], + Union[ + contact_center_insights.CalculateStatsResponse, + Awaitable[contact_center_insights.CalculateStatsResponse] + ]]: + raise NotImplementedError() + + @property + def get_settings(self) -> Callable[ + [contact_center_insights.GetSettingsRequest], + Union[ + resources.Settings, + Awaitable[resources.Settings] + ]]: + raise NotImplementedError() + + @property + def update_settings(self) -> Callable[ + [contact_center_insights.UpdateSettingsRequest], + Union[ + resources.Settings, + Awaitable[resources.Settings] + ]]: + raise NotImplementedError() + + @property + def create_view(self) -> Callable[ + [contact_center_insights.CreateViewRequest], + Union[ + resources.View, + Awaitable[resources.View] + ]]: + raise NotImplementedError() + + @property + def get_view(self) -> Callable[ + [contact_center_insights.GetViewRequest], + Union[ + resources.View, + Awaitable[resources.View] + ]]: + raise NotImplementedError() + + @property + def list_views(self) -> Callable[ + [contact_center_insights.ListViewsRequest], + Union[ + contact_center_insights.ListViewsResponse, + Awaitable[contact_center_insights.ListViewsResponse] + ]]: + raise NotImplementedError() + + @property + def update_view(self) -> Callable[ + [contact_center_insights.UpdateViewRequest], + Union[ + resources.View, + Awaitable[resources.View] + ]]: + raise NotImplementedError() + + @property + def delete_view(self) -> Callable[ + [contact_center_insights.DeleteViewRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def list_operations( + self, + ) -> Callable[ + [operations_pb2.ListOperationsRequest], + Union[operations_pb2.ListOperationsResponse, Awaitable[operations_pb2.ListOperationsResponse]], + ]: + raise NotImplementedError() + + @property + def get_operation( + self, + ) -> Callable[ + [operations_pb2.GetOperationRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def cancel_operation( + self, + ) -> Callable[ + [operations_pb2.CancelOperationRequest], + None, + ]: + raise NotImplementedError() + + @property + def kind(self) -> str: + raise NotImplementedError() + + +__all__ = ( + 'ContactCenterInsightsTransport', +) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py new file mode 100644 index 000000000000..252a4273d43e --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py @@ -0,0 +1,1311 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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 warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers +from google.api_core import operations_v1 +from google.api_core import gapic_v1 +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.contact_center_insights_v1.types import contact_center_insights +from google.cloud.contact_center_insights_v1.types import resources +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from .base import ContactCenterInsightsTransport, DEFAULT_CLIENT_INFO + + +class ContactCenterInsightsGrpcTransport(ContactCenterInsightsTransport): + """gRPC backend transport for ContactCenterInsights. + + An API that lets users analyze and explore their business + conversation data. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends protocol buffers over the wire using gRPC (which is built on + top of HTTP/2); the ``grpcio`` package must be installed. + """ + _stubs: Dict[str, Callable] + + def __init__(self, *, + host: str = 'contactcenterinsights.googleapis.com', + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: Optional[grpc.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if ``channel`` is provided. + channel (Optional[grpc.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or application default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for the grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure a mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client: Optional[operations_v1.OperationsClient] = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + # use the credentials which are saved + credentials=self._credentials, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @classmethod + def create_channel(cls, + host: str = 'contactcenterinsights.googleapis.com', + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> grpc.Channel: + """Create and return a gRPC channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + grpc.Channel: A gRPC channel object. + + Raises: + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + + return grpc_helpers.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, + **kwargs + ) + + @property + def grpc_channel(self) -> grpc.Channel: + """Return the channel designed to connect to this service. + """ + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Quick check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def create_conversation(self) -> Callable[ + [contact_center_insights.CreateConversationRequest], + resources.Conversation]: + r"""Return a callable for the create conversation method over gRPC. + + Creates a conversation. + + Returns: + Callable[[~.CreateConversationRequest], + ~.Conversation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_conversation' not in self._stubs: + self._stubs['create_conversation'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateConversation', + request_serializer=contact_center_insights.CreateConversationRequest.serialize, + response_deserializer=resources.Conversation.deserialize, + ) + return self._stubs['create_conversation'] + + @property + def upload_conversation(self) -> Callable[ + [contact_center_insights.UploadConversationRequest], + operations_pb2.Operation]: + r"""Return a callable for the upload conversation method over gRPC. + + Create a longrunning conversation upload operation. + This method differs from CreateConversation by allowing + audio transcription and optional DLP redaction. + + Returns: + Callable[[~.UploadConversationRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'upload_conversation' not in self._stubs: + self._stubs['upload_conversation'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UploadConversation', + request_serializer=contact_center_insights.UploadConversationRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['upload_conversation'] + + @property + def update_conversation(self) -> Callable[ + [contact_center_insights.UpdateConversationRequest], + resources.Conversation]: + r"""Return a callable for the update conversation method over gRPC. + + Updates a conversation. + + Returns: + Callable[[~.UpdateConversationRequest], + ~.Conversation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_conversation' not in self._stubs: + self._stubs['update_conversation'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateConversation', + request_serializer=contact_center_insights.UpdateConversationRequest.serialize, + response_deserializer=resources.Conversation.deserialize, + ) + return self._stubs['update_conversation'] + + @property + def get_conversation(self) -> Callable[ + [contact_center_insights.GetConversationRequest], + resources.Conversation]: + r"""Return a callable for the get conversation method over gRPC. + + Gets a conversation. + + Returns: + Callable[[~.GetConversationRequest], + ~.Conversation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'get_conversation' not in self._stubs: + self._stubs['get_conversation'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetConversation', + request_serializer=contact_center_insights.GetConversationRequest.serialize, + response_deserializer=resources.Conversation.deserialize, + ) + return self._stubs['get_conversation'] + + @property + def list_conversations(self) -> Callable[ + [contact_center_insights.ListConversationsRequest], + contact_center_insights.ListConversationsResponse]: + r"""Return a callable for the list conversations method over gRPC. + + Lists conversations. + + Returns: + Callable[[~.ListConversationsRequest], + ~.ListConversationsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'list_conversations' not in self._stubs: + self._stubs['list_conversations'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListConversations', + request_serializer=contact_center_insights.ListConversationsRequest.serialize, + response_deserializer=contact_center_insights.ListConversationsResponse.deserialize, + ) + return self._stubs['list_conversations'] + + @property + def delete_conversation(self) -> Callable[ + [contact_center_insights.DeleteConversationRequest], + empty_pb2.Empty]: + r"""Return a callable for the delete conversation method over gRPC. + + Deletes a conversation. + + Returns: + Callable[[~.DeleteConversationRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_conversation' not in self._stubs: + self._stubs['delete_conversation'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteConversation', + request_serializer=contact_center_insights.DeleteConversationRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_conversation'] + + @property + def create_analysis(self) -> Callable[ + [contact_center_insights.CreateAnalysisRequest], + operations_pb2.Operation]: + r"""Return a callable for the create analysis method over gRPC. + + Creates an analysis. The long running operation is + done when the analysis has completed. + + Returns: + Callable[[~.CreateAnalysisRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_analysis' not in self._stubs: + self._stubs['create_analysis'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateAnalysis', + request_serializer=contact_center_insights.CreateAnalysisRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_analysis'] + + @property + def get_analysis(self) -> Callable[ + [contact_center_insights.GetAnalysisRequest], + resources.Analysis]: + r"""Return a callable for the get analysis method over gRPC. + + Gets an analysis. + + Returns: + Callable[[~.GetAnalysisRequest], + ~.Analysis]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'get_analysis' not in self._stubs: + self._stubs['get_analysis'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetAnalysis', + request_serializer=contact_center_insights.GetAnalysisRequest.serialize, + response_deserializer=resources.Analysis.deserialize, + ) + return self._stubs['get_analysis'] + + @property + def list_analyses(self) -> Callable[ + [contact_center_insights.ListAnalysesRequest], + contact_center_insights.ListAnalysesResponse]: + r"""Return a callable for the list analyses method over gRPC. + + Lists analyses. + + Returns: + Callable[[~.ListAnalysesRequest], + ~.ListAnalysesResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'list_analyses' not in self._stubs: + self._stubs['list_analyses'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListAnalyses', + request_serializer=contact_center_insights.ListAnalysesRequest.serialize, + response_deserializer=contact_center_insights.ListAnalysesResponse.deserialize, + ) + return self._stubs['list_analyses'] + + @property + def delete_analysis(self) -> Callable[ + [contact_center_insights.DeleteAnalysisRequest], + empty_pb2.Empty]: + r"""Return a callable for the delete analysis method over gRPC. + + Deletes an analysis. + + Returns: + Callable[[~.DeleteAnalysisRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_analysis' not in self._stubs: + self._stubs['delete_analysis'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteAnalysis', + request_serializer=contact_center_insights.DeleteAnalysisRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_analysis'] + + @property + def bulk_analyze_conversations(self) -> Callable[ + [contact_center_insights.BulkAnalyzeConversationsRequest], + operations_pb2.Operation]: + r"""Return a callable for the bulk analyze conversations method over gRPC. + + Analyzes multiple conversations in a single request. + + Returns: + Callable[[~.BulkAnalyzeConversationsRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'bulk_analyze_conversations' not in self._stubs: + self._stubs['bulk_analyze_conversations'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/BulkAnalyzeConversations', + request_serializer=contact_center_insights.BulkAnalyzeConversationsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['bulk_analyze_conversations'] + + @property + def ingest_conversations(self) -> Callable[ + [contact_center_insights.IngestConversationsRequest], + operations_pb2.Operation]: + r"""Return a callable for the ingest conversations method over gRPC. + + Imports conversations and processes them according to + the user's configuration. + + Returns: + Callable[[~.IngestConversationsRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'ingest_conversations' not in self._stubs: + self._stubs['ingest_conversations'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/IngestConversations', + request_serializer=contact_center_insights.IngestConversationsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['ingest_conversations'] + + @property + def export_insights_data(self) -> Callable[ + [contact_center_insights.ExportInsightsDataRequest], + operations_pb2.Operation]: + r"""Return a callable for the export insights data method over gRPC. + + Export insights data to a destination defined in the + request body. + + Returns: + Callable[[~.ExportInsightsDataRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'export_insights_data' not in self._stubs: + self._stubs['export_insights_data'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ExportInsightsData', + request_serializer=contact_center_insights.ExportInsightsDataRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['export_insights_data'] + + @property + def create_issue_model(self) -> Callable[ + [contact_center_insights.CreateIssueModelRequest], + operations_pb2.Operation]: + r"""Return a callable for the create issue model method over gRPC. + + Creates an issue model. + + Returns: + Callable[[~.CreateIssueModelRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_issue_model' not in self._stubs: + self._stubs['create_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateIssueModel', + request_serializer=contact_center_insights.CreateIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_issue_model'] + + @property + def update_issue_model(self) -> Callable[ + [contact_center_insights.UpdateIssueModelRequest], + resources.IssueModel]: + r"""Return a callable for the update issue model method over gRPC. + + Updates an issue model. + + Returns: + Callable[[~.UpdateIssueModelRequest], + ~.IssueModel]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_issue_model' not in self._stubs: + self._stubs['update_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateIssueModel', + request_serializer=contact_center_insights.UpdateIssueModelRequest.serialize, + response_deserializer=resources.IssueModel.deserialize, + ) + return self._stubs['update_issue_model'] + + @property + def get_issue_model(self) -> Callable[ + [contact_center_insights.GetIssueModelRequest], + resources.IssueModel]: + r"""Return a callable for the get issue model method over gRPC. + + Gets an issue model. + + Returns: + Callable[[~.GetIssueModelRequest], + ~.IssueModel]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'get_issue_model' not in self._stubs: + self._stubs['get_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetIssueModel', + request_serializer=contact_center_insights.GetIssueModelRequest.serialize, + response_deserializer=resources.IssueModel.deserialize, + ) + return self._stubs['get_issue_model'] + + @property + def list_issue_models(self) -> Callable[ + [contact_center_insights.ListIssueModelsRequest], + contact_center_insights.ListIssueModelsResponse]: + r"""Return a callable for the list issue models method over gRPC. + + Lists issue models. + + Returns: + Callable[[~.ListIssueModelsRequest], + ~.ListIssueModelsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'list_issue_models' not in self._stubs: + self._stubs['list_issue_models'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListIssueModels', + request_serializer=contact_center_insights.ListIssueModelsRequest.serialize, + response_deserializer=contact_center_insights.ListIssueModelsResponse.deserialize, + ) + return self._stubs['list_issue_models'] + + @property + def delete_issue_model(self) -> Callable[ + [contact_center_insights.DeleteIssueModelRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete issue model method over gRPC. + + Deletes an issue model. + + Returns: + Callable[[~.DeleteIssueModelRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_issue_model' not in self._stubs: + self._stubs['delete_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteIssueModel', + request_serializer=contact_center_insights.DeleteIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_issue_model'] + + @property + def deploy_issue_model(self) -> Callable[ + [contact_center_insights.DeployIssueModelRequest], + operations_pb2.Operation]: + r"""Return a callable for the deploy issue model method over gRPC. + + Deploys an issue model. Returns an error if a model + is already deployed. An issue model can only be used in + analysis after it has been deployed. + + Returns: + Callable[[~.DeployIssueModelRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'deploy_issue_model' not in self._stubs: + self._stubs['deploy_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeployIssueModel', + request_serializer=contact_center_insights.DeployIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['deploy_issue_model'] + + @property + def undeploy_issue_model(self) -> Callable[ + [contact_center_insights.UndeployIssueModelRequest], + operations_pb2.Operation]: + r"""Return a callable for the undeploy issue model method over gRPC. + + Undeploys an issue model. + An issue model can not be used in analysis after it has + been undeployed. + + Returns: + Callable[[~.UndeployIssueModelRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'undeploy_issue_model' not in self._stubs: + self._stubs['undeploy_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UndeployIssueModel', + request_serializer=contact_center_insights.UndeployIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['undeploy_issue_model'] + + @property + def get_issue(self) -> Callable[ + [contact_center_insights.GetIssueRequest], + resources.Issue]: + r"""Return a callable for the get issue method over gRPC. + + Gets an issue. + + Returns: + Callable[[~.GetIssueRequest], + ~.Issue]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'get_issue' not in self._stubs: + self._stubs['get_issue'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetIssue', + request_serializer=contact_center_insights.GetIssueRequest.serialize, + response_deserializer=resources.Issue.deserialize, + ) + return self._stubs['get_issue'] + + @property + def list_issues(self) -> Callable[ + [contact_center_insights.ListIssuesRequest], + contact_center_insights.ListIssuesResponse]: + r"""Return a callable for the list issues method over gRPC. + + Lists issues. + + Returns: + Callable[[~.ListIssuesRequest], + ~.ListIssuesResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'list_issues' not in self._stubs: + self._stubs['list_issues'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListIssues', + request_serializer=contact_center_insights.ListIssuesRequest.serialize, + response_deserializer=contact_center_insights.ListIssuesResponse.deserialize, + ) + return self._stubs['list_issues'] + + @property + def update_issue(self) -> Callable[ + [contact_center_insights.UpdateIssueRequest], + resources.Issue]: + r"""Return a callable for the update issue method over gRPC. + + Updates an issue. + + Returns: + Callable[[~.UpdateIssueRequest], + ~.Issue]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_issue' not in self._stubs: + self._stubs['update_issue'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateIssue', + request_serializer=contact_center_insights.UpdateIssueRequest.serialize, + response_deserializer=resources.Issue.deserialize, + ) + return self._stubs['update_issue'] + + @property + def delete_issue(self) -> Callable[ + [contact_center_insights.DeleteIssueRequest], + empty_pb2.Empty]: + r"""Return a callable for the delete issue method over gRPC. + + Deletes an issue. + + Returns: + Callable[[~.DeleteIssueRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_issue' not in self._stubs: + self._stubs['delete_issue'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteIssue', + request_serializer=contact_center_insights.DeleteIssueRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_issue'] + + @property + def calculate_issue_model_stats(self) -> Callable[ + [contact_center_insights.CalculateIssueModelStatsRequest], + contact_center_insights.CalculateIssueModelStatsResponse]: + r"""Return a callable for the calculate issue model stats method over gRPC. + + Gets an issue model's statistics. + + Returns: + Callable[[~.CalculateIssueModelStatsRequest], + ~.CalculateIssueModelStatsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'calculate_issue_model_stats' not in self._stubs: + self._stubs['calculate_issue_model_stats'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CalculateIssueModelStats', + request_serializer=contact_center_insights.CalculateIssueModelStatsRequest.serialize, + response_deserializer=contact_center_insights.CalculateIssueModelStatsResponse.deserialize, + ) + return self._stubs['calculate_issue_model_stats'] + + @property + def create_phrase_matcher(self) -> Callable[ + [contact_center_insights.CreatePhraseMatcherRequest], + resources.PhraseMatcher]: + r"""Return a callable for the create phrase matcher method over gRPC. + + Creates a phrase matcher. + + Returns: + Callable[[~.CreatePhraseMatcherRequest], + ~.PhraseMatcher]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_phrase_matcher' not in self._stubs: + self._stubs['create_phrase_matcher'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreatePhraseMatcher', + request_serializer=contact_center_insights.CreatePhraseMatcherRequest.serialize, + response_deserializer=resources.PhraseMatcher.deserialize, + ) + return self._stubs['create_phrase_matcher'] + + @property + def get_phrase_matcher(self) -> Callable[ + [contact_center_insights.GetPhraseMatcherRequest], + resources.PhraseMatcher]: + r"""Return a callable for the get phrase matcher method over gRPC. + + Gets a phrase matcher. + + Returns: + Callable[[~.GetPhraseMatcherRequest], + ~.PhraseMatcher]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'get_phrase_matcher' not in self._stubs: + self._stubs['get_phrase_matcher'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetPhraseMatcher', + request_serializer=contact_center_insights.GetPhraseMatcherRequest.serialize, + response_deserializer=resources.PhraseMatcher.deserialize, + ) + return self._stubs['get_phrase_matcher'] + + @property + def list_phrase_matchers(self) -> Callable[ + [contact_center_insights.ListPhraseMatchersRequest], + contact_center_insights.ListPhraseMatchersResponse]: + r"""Return a callable for the list phrase matchers method over gRPC. + + Lists phrase matchers. + + Returns: + Callable[[~.ListPhraseMatchersRequest], + ~.ListPhraseMatchersResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'list_phrase_matchers' not in self._stubs: + self._stubs['list_phrase_matchers'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListPhraseMatchers', + request_serializer=contact_center_insights.ListPhraseMatchersRequest.serialize, + response_deserializer=contact_center_insights.ListPhraseMatchersResponse.deserialize, + ) + return self._stubs['list_phrase_matchers'] + + @property + def delete_phrase_matcher(self) -> Callable[ + [contact_center_insights.DeletePhraseMatcherRequest], + empty_pb2.Empty]: + r"""Return a callable for the delete phrase matcher method over gRPC. + + Deletes a phrase matcher. + + Returns: + Callable[[~.DeletePhraseMatcherRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_phrase_matcher' not in self._stubs: + self._stubs['delete_phrase_matcher'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeletePhraseMatcher', + request_serializer=contact_center_insights.DeletePhraseMatcherRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_phrase_matcher'] + + @property + def update_phrase_matcher(self) -> Callable[ + [contact_center_insights.UpdatePhraseMatcherRequest], + resources.PhraseMatcher]: + r"""Return a callable for the update phrase matcher method over gRPC. + + Updates a phrase matcher. + + Returns: + Callable[[~.UpdatePhraseMatcherRequest], + ~.PhraseMatcher]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_phrase_matcher' not in self._stubs: + self._stubs['update_phrase_matcher'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdatePhraseMatcher', + request_serializer=contact_center_insights.UpdatePhraseMatcherRequest.serialize, + response_deserializer=resources.PhraseMatcher.deserialize, + ) + return self._stubs['update_phrase_matcher'] + + @property + def calculate_stats(self) -> Callable[ + [contact_center_insights.CalculateStatsRequest], + contact_center_insights.CalculateStatsResponse]: + r"""Return a callable for the calculate stats method over gRPC. + + Gets conversation statistics. + + Returns: + Callable[[~.CalculateStatsRequest], + ~.CalculateStatsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'calculate_stats' not in self._stubs: + self._stubs['calculate_stats'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CalculateStats', + request_serializer=contact_center_insights.CalculateStatsRequest.serialize, + response_deserializer=contact_center_insights.CalculateStatsResponse.deserialize, + ) + return self._stubs['calculate_stats'] + + @property + def get_settings(self) -> Callable[ + [contact_center_insights.GetSettingsRequest], + resources.Settings]: + r"""Return a callable for the get settings method over gRPC. + + Gets project-level settings. + + Returns: + Callable[[~.GetSettingsRequest], + ~.Settings]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'get_settings' not in self._stubs: + self._stubs['get_settings'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetSettings', + request_serializer=contact_center_insights.GetSettingsRequest.serialize, + response_deserializer=resources.Settings.deserialize, + ) + return self._stubs['get_settings'] + + @property + def update_settings(self) -> Callable[ + [contact_center_insights.UpdateSettingsRequest], + resources.Settings]: + r"""Return a callable for the update settings method over gRPC. + + Updates project-level settings. + + Returns: + Callable[[~.UpdateSettingsRequest], + ~.Settings]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_settings' not in self._stubs: + self._stubs['update_settings'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateSettings', + request_serializer=contact_center_insights.UpdateSettingsRequest.serialize, + response_deserializer=resources.Settings.deserialize, + ) + return self._stubs['update_settings'] + + @property + def create_view(self) -> Callable[ + [contact_center_insights.CreateViewRequest], + resources.View]: + r"""Return a callable for the create view method over gRPC. + + Creates a view. + + Returns: + Callable[[~.CreateViewRequest], + ~.View]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_view' not in self._stubs: + self._stubs['create_view'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateView', + request_serializer=contact_center_insights.CreateViewRequest.serialize, + response_deserializer=resources.View.deserialize, + ) + return self._stubs['create_view'] + + @property + def get_view(self) -> Callable[ + [contact_center_insights.GetViewRequest], + resources.View]: + r"""Return a callable for the get view method over gRPC. + + Gets a view. + + Returns: + Callable[[~.GetViewRequest], + ~.View]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'get_view' not in self._stubs: + self._stubs['get_view'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetView', + request_serializer=contact_center_insights.GetViewRequest.serialize, + response_deserializer=resources.View.deserialize, + ) + return self._stubs['get_view'] + + @property + def list_views(self) -> Callable[ + [contact_center_insights.ListViewsRequest], + contact_center_insights.ListViewsResponse]: + r"""Return a callable for the list views method over gRPC. + + Lists views. + + Returns: + Callable[[~.ListViewsRequest], + ~.ListViewsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'list_views' not in self._stubs: + self._stubs['list_views'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListViews', + request_serializer=contact_center_insights.ListViewsRequest.serialize, + response_deserializer=contact_center_insights.ListViewsResponse.deserialize, + ) + return self._stubs['list_views'] + + @property + def update_view(self) -> Callable[ + [contact_center_insights.UpdateViewRequest], + resources.View]: + r"""Return a callable for the update view method over gRPC. + + Updates a view. + + Returns: + Callable[[~.UpdateViewRequest], + ~.View]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_view' not in self._stubs: + self._stubs['update_view'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateView', + request_serializer=contact_center_insights.UpdateViewRequest.serialize, + response_deserializer=resources.View.deserialize, + ) + return self._stubs['update_view'] + + @property + def delete_view(self) -> Callable[ + [contact_center_insights.DeleteViewRequest], + empty_pb2.Empty]: + r"""Return a callable for the delete view method over gRPC. + + Deletes a view. + + Returns: + Callable[[~.DeleteViewRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_view' not in self._stubs: + self._stubs['delete_view'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteView', + request_serializer=contact_center_insights.DeleteViewRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_view'] + + def close(self): + self.grpc_channel.close() + + @property + def cancel_operation( + self, + ) -> Callable[[operations_pb2.CancelOperationRequest], None]: + r"""Return a callable for the cancel_operation method over gRPC. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "cancel_operation" not in self._stubs: + self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/CancelOperation", + request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, + response_deserializer=None, + ) + return self._stubs["cancel_operation"] + + @property + def get_operation( + self, + ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: + r"""Return a callable for the get_operation method over gRPC. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_operation" not in self._stubs: + self._stubs["get_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/GetOperation", + request_serializer=operations_pb2.GetOperationRequest.SerializeToString, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["get_operation"] + + @property + def list_operations( + self, + ) -> Callable[[operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse]: + r"""Return a callable for the list_operations method over gRPC. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_operations" not in self._stubs: + self._stubs["list_operations"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/ListOperations", + request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, + response_deserializer=operations_pb2.ListOperationsResponse.FromString, + ) + return self._stubs["list_operations"] + + @property + def kind(self) -> str: + return "grpc" + + +__all__ = ( + 'ContactCenterInsightsGrpcTransport', +) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py new file mode 100644 index 000000000000..a1d6b42a82d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py @@ -0,0 +1,1310 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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 warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async +from google.api_core import operations_v1 +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.contact_center_insights_v1.types import contact_center_insights +from google.cloud.contact_center_insights_v1.types import resources +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from .base import ContactCenterInsightsTransport, DEFAULT_CLIENT_INFO +from .grpc import ContactCenterInsightsGrpcTransport + + +class ContactCenterInsightsGrpcAsyncIOTransport(ContactCenterInsightsTransport): + """gRPC AsyncIO backend transport for ContactCenterInsights. + + An API that lets users analyze and explore their business + conversation data. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends protocol buffers over the wire using gRPC (which is built on + top of HTTP/2); the ``grpcio`` package must be installed. + """ + + _grpc_channel: aio.Channel + _stubs: Dict[str, Callable] = {} + + @classmethod + def create_channel(cls, + host: str = 'contactcenterinsights.googleapis.com', + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> aio.Channel: + """Create and return a gRPC AsyncIO channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + aio.Channel: A gRPC AsyncIO channel object. + """ + + return grpc_helpers_async.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, + **kwargs + ) + + def __init__(self, *, + host: str = 'contactcenterinsights.googleapis.com', + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: Optional[aio.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + channel (Optional[aio.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or application default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for the grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure a mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + # use the credentials which are saved + credentials=self._credentials, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @property + def grpc_channel(self) -> aio.Channel: + """Create the channel designed to connect to this service. + + This property caches on the instance; repeated calls return + the same channel. + """ + # Return the channel from cache. + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsAsyncClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Quick check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsAsyncClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def create_conversation(self) -> Callable[ + [contact_center_insights.CreateConversationRequest], + Awaitable[resources.Conversation]]: + r"""Return a callable for the create conversation method over gRPC. + + Creates a conversation. + + Returns: + Callable[[~.CreateConversationRequest], + Awaitable[~.Conversation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_conversation' not in self._stubs: + self._stubs['create_conversation'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateConversation', + request_serializer=contact_center_insights.CreateConversationRequest.serialize, + response_deserializer=resources.Conversation.deserialize, + ) + return self._stubs['create_conversation'] + + @property + def upload_conversation(self) -> Callable[ + [contact_center_insights.UploadConversationRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the upload conversation method over gRPC. + + Create a longrunning conversation upload operation. + This method differs from CreateConversation by allowing + audio transcription and optional DLP redaction. + + Returns: + Callable[[~.UploadConversationRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'upload_conversation' not in self._stubs: + self._stubs['upload_conversation'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UploadConversation', + request_serializer=contact_center_insights.UploadConversationRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['upload_conversation'] + + @property + def update_conversation(self) -> Callable[ + [contact_center_insights.UpdateConversationRequest], + Awaitable[resources.Conversation]]: + r"""Return a callable for the update conversation method over gRPC. + + Updates a conversation. + + Returns: + Callable[[~.UpdateConversationRequest], + Awaitable[~.Conversation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_conversation' not in self._stubs: + self._stubs['update_conversation'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateConversation', + request_serializer=contact_center_insights.UpdateConversationRequest.serialize, + response_deserializer=resources.Conversation.deserialize, + ) + return self._stubs['update_conversation'] + + @property + def get_conversation(self) -> Callable[ + [contact_center_insights.GetConversationRequest], + Awaitable[resources.Conversation]]: + r"""Return a callable for the get conversation method over gRPC. + + Gets a conversation. + + Returns: + Callable[[~.GetConversationRequest], + Awaitable[~.Conversation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'get_conversation' not in self._stubs: + self._stubs['get_conversation'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetConversation', + request_serializer=contact_center_insights.GetConversationRequest.serialize, + response_deserializer=resources.Conversation.deserialize, + ) + return self._stubs['get_conversation'] + + @property + def list_conversations(self) -> Callable[ + [contact_center_insights.ListConversationsRequest], + Awaitable[contact_center_insights.ListConversationsResponse]]: + r"""Return a callable for the list conversations method over gRPC. + + Lists conversations. + + Returns: + Callable[[~.ListConversationsRequest], + Awaitable[~.ListConversationsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'list_conversations' not in self._stubs: + self._stubs['list_conversations'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListConversations', + request_serializer=contact_center_insights.ListConversationsRequest.serialize, + response_deserializer=contact_center_insights.ListConversationsResponse.deserialize, + ) + return self._stubs['list_conversations'] + + @property + def delete_conversation(self) -> Callable[ + [contact_center_insights.DeleteConversationRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete conversation method over gRPC. + + Deletes a conversation. + + Returns: + Callable[[~.DeleteConversationRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_conversation' not in self._stubs: + self._stubs['delete_conversation'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteConversation', + request_serializer=contact_center_insights.DeleteConversationRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_conversation'] + + @property + def create_analysis(self) -> Callable[ + [contact_center_insights.CreateAnalysisRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create analysis method over gRPC. + + Creates an analysis. The long running operation is + done when the analysis has completed. + + Returns: + Callable[[~.CreateAnalysisRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_analysis' not in self._stubs: + self._stubs['create_analysis'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateAnalysis', + request_serializer=contact_center_insights.CreateAnalysisRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_analysis'] + + @property + def get_analysis(self) -> Callable[ + [contact_center_insights.GetAnalysisRequest], + Awaitable[resources.Analysis]]: + r"""Return a callable for the get analysis method over gRPC. + + Gets an analysis. + + Returns: + Callable[[~.GetAnalysisRequest], + Awaitable[~.Analysis]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'get_analysis' not in self._stubs: + self._stubs['get_analysis'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetAnalysis', + request_serializer=contact_center_insights.GetAnalysisRequest.serialize, + response_deserializer=resources.Analysis.deserialize, + ) + return self._stubs['get_analysis'] + + @property + def list_analyses(self) -> Callable[ + [contact_center_insights.ListAnalysesRequest], + Awaitable[contact_center_insights.ListAnalysesResponse]]: + r"""Return a callable for the list analyses method over gRPC. + + Lists analyses. + + Returns: + Callable[[~.ListAnalysesRequest], + Awaitable[~.ListAnalysesResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'list_analyses' not in self._stubs: + self._stubs['list_analyses'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListAnalyses', + request_serializer=contact_center_insights.ListAnalysesRequest.serialize, + response_deserializer=contact_center_insights.ListAnalysesResponse.deserialize, + ) + return self._stubs['list_analyses'] + + @property + def delete_analysis(self) -> Callable[ + [contact_center_insights.DeleteAnalysisRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete analysis method over gRPC. + + Deletes an analysis. + + Returns: + Callable[[~.DeleteAnalysisRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_analysis' not in self._stubs: + self._stubs['delete_analysis'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteAnalysis', + request_serializer=contact_center_insights.DeleteAnalysisRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_analysis'] + + @property + def bulk_analyze_conversations(self) -> Callable[ + [contact_center_insights.BulkAnalyzeConversationsRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the bulk analyze conversations method over gRPC. + + Analyzes multiple conversations in a single request. + + Returns: + Callable[[~.BulkAnalyzeConversationsRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'bulk_analyze_conversations' not in self._stubs: + self._stubs['bulk_analyze_conversations'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/BulkAnalyzeConversations', + request_serializer=contact_center_insights.BulkAnalyzeConversationsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['bulk_analyze_conversations'] + + @property + def ingest_conversations(self) -> Callable[ + [contact_center_insights.IngestConversationsRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the ingest conversations method over gRPC. + + Imports conversations and processes them according to + the user's configuration. + + Returns: + Callable[[~.IngestConversationsRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'ingest_conversations' not in self._stubs: + self._stubs['ingest_conversations'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/IngestConversations', + request_serializer=contact_center_insights.IngestConversationsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['ingest_conversations'] + + @property + def export_insights_data(self) -> Callable[ + [contact_center_insights.ExportInsightsDataRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the export insights data method over gRPC. + + Export insights data to a destination defined in the + request body. + + Returns: + Callable[[~.ExportInsightsDataRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'export_insights_data' not in self._stubs: + self._stubs['export_insights_data'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ExportInsightsData', + request_serializer=contact_center_insights.ExportInsightsDataRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['export_insights_data'] + + @property + def create_issue_model(self) -> Callable[ + [contact_center_insights.CreateIssueModelRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create issue model method over gRPC. + + Creates an issue model. + + Returns: + Callable[[~.CreateIssueModelRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_issue_model' not in self._stubs: + self._stubs['create_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateIssueModel', + request_serializer=contact_center_insights.CreateIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_issue_model'] + + @property + def update_issue_model(self) -> Callable[ + [contact_center_insights.UpdateIssueModelRequest], + Awaitable[resources.IssueModel]]: + r"""Return a callable for the update issue model method over gRPC. + + Updates an issue model. + + Returns: + Callable[[~.UpdateIssueModelRequest], + Awaitable[~.IssueModel]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_issue_model' not in self._stubs: + self._stubs['update_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateIssueModel', + request_serializer=contact_center_insights.UpdateIssueModelRequest.serialize, + response_deserializer=resources.IssueModel.deserialize, + ) + return self._stubs['update_issue_model'] + + @property + def get_issue_model(self) -> Callable[ + [contact_center_insights.GetIssueModelRequest], + Awaitable[resources.IssueModel]]: + r"""Return a callable for the get issue model method over gRPC. + + Gets an issue model. + + Returns: + Callable[[~.GetIssueModelRequest], + Awaitable[~.IssueModel]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'get_issue_model' not in self._stubs: + self._stubs['get_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetIssueModel', + request_serializer=contact_center_insights.GetIssueModelRequest.serialize, + response_deserializer=resources.IssueModel.deserialize, + ) + return self._stubs['get_issue_model'] + + @property + def list_issue_models(self) -> Callable[ + [contact_center_insights.ListIssueModelsRequest], + Awaitable[contact_center_insights.ListIssueModelsResponse]]: + r"""Return a callable for the list issue models method over gRPC. + + Lists issue models. + + Returns: + Callable[[~.ListIssueModelsRequest], + Awaitable[~.ListIssueModelsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'list_issue_models' not in self._stubs: + self._stubs['list_issue_models'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListIssueModels', + request_serializer=contact_center_insights.ListIssueModelsRequest.serialize, + response_deserializer=contact_center_insights.ListIssueModelsResponse.deserialize, + ) + return self._stubs['list_issue_models'] + + @property + def delete_issue_model(self) -> Callable[ + [contact_center_insights.DeleteIssueModelRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete issue model method over gRPC. + + Deletes an issue model. + + Returns: + Callable[[~.DeleteIssueModelRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_issue_model' not in self._stubs: + self._stubs['delete_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteIssueModel', + request_serializer=contact_center_insights.DeleteIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_issue_model'] + + @property + def deploy_issue_model(self) -> Callable[ + [contact_center_insights.DeployIssueModelRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the deploy issue model method over gRPC. + + Deploys an issue model. Returns an error if a model + is already deployed. An issue model can only be used in + analysis after it has been deployed. + + Returns: + Callable[[~.DeployIssueModelRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'deploy_issue_model' not in self._stubs: + self._stubs['deploy_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeployIssueModel', + request_serializer=contact_center_insights.DeployIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['deploy_issue_model'] + + @property + def undeploy_issue_model(self) -> Callable[ + [contact_center_insights.UndeployIssueModelRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the undeploy issue model method over gRPC. + + Undeploys an issue model. + An issue model can not be used in analysis after it has + been undeployed. + + Returns: + Callable[[~.UndeployIssueModelRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'undeploy_issue_model' not in self._stubs: + self._stubs['undeploy_issue_model'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UndeployIssueModel', + request_serializer=contact_center_insights.UndeployIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['undeploy_issue_model'] + + @property + def get_issue(self) -> Callable[ + [contact_center_insights.GetIssueRequest], + Awaitable[resources.Issue]]: + r"""Return a callable for the get issue method over gRPC. + + Gets an issue. + + Returns: + Callable[[~.GetIssueRequest], + Awaitable[~.Issue]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'get_issue' not in self._stubs: + self._stubs['get_issue'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetIssue', + request_serializer=contact_center_insights.GetIssueRequest.serialize, + response_deserializer=resources.Issue.deserialize, + ) + return self._stubs['get_issue'] + + @property + def list_issues(self) -> Callable[ + [contact_center_insights.ListIssuesRequest], + Awaitable[contact_center_insights.ListIssuesResponse]]: + r"""Return a callable for the list issues method over gRPC. + + Lists issues. + + Returns: + Callable[[~.ListIssuesRequest], + Awaitable[~.ListIssuesResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'list_issues' not in self._stubs: + self._stubs['list_issues'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListIssues', + request_serializer=contact_center_insights.ListIssuesRequest.serialize, + response_deserializer=contact_center_insights.ListIssuesResponse.deserialize, + ) + return self._stubs['list_issues'] + + @property + def update_issue(self) -> Callable[ + [contact_center_insights.UpdateIssueRequest], + Awaitable[resources.Issue]]: + r"""Return a callable for the update issue method over gRPC. + + Updates an issue. + + Returns: + Callable[[~.UpdateIssueRequest], + Awaitable[~.Issue]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_issue' not in self._stubs: + self._stubs['update_issue'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateIssue', + request_serializer=contact_center_insights.UpdateIssueRequest.serialize, + response_deserializer=resources.Issue.deserialize, + ) + return self._stubs['update_issue'] + + @property + def delete_issue(self) -> Callable[ + [contact_center_insights.DeleteIssueRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete issue method over gRPC. + + Deletes an issue. + + Returns: + Callable[[~.DeleteIssueRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_issue' not in self._stubs: + self._stubs['delete_issue'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteIssue', + request_serializer=contact_center_insights.DeleteIssueRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_issue'] + + @property + def calculate_issue_model_stats(self) -> Callable[ + [contact_center_insights.CalculateIssueModelStatsRequest], + Awaitable[contact_center_insights.CalculateIssueModelStatsResponse]]: + r"""Return a callable for the calculate issue model stats method over gRPC. + + Gets an issue model's statistics. + + Returns: + Callable[[~.CalculateIssueModelStatsRequest], + Awaitable[~.CalculateIssueModelStatsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'calculate_issue_model_stats' not in self._stubs: + self._stubs['calculate_issue_model_stats'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CalculateIssueModelStats', + request_serializer=contact_center_insights.CalculateIssueModelStatsRequest.serialize, + response_deserializer=contact_center_insights.CalculateIssueModelStatsResponse.deserialize, + ) + return self._stubs['calculate_issue_model_stats'] + + @property + def create_phrase_matcher(self) -> Callable[ + [contact_center_insights.CreatePhraseMatcherRequest], + Awaitable[resources.PhraseMatcher]]: + r"""Return a callable for the create phrase matcher method over gRPC. + + Creates a phrase matcher. + + Returns: + Callable[[~.CreatePhraseMatcherRequest], + Awaitable[~.PhraseMatcher]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_phrase_matcher' not in self._stubs: + self._stubs['create_phrase_matcher'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreatePhraseMatcher', + request_serializer=contact_center_insights.CreatePhraseMatcherRequest.serialize, + response_deserializer=resources.PhraseMatcher.deserialize, + ) + return self._stubs['create_phrase_matcher'] + + @property + def get_phrase_matcher(self) -> Callable[ + [contact_center_insights.GetPhraseMatcherRequest], + Awaitable[resources.PhraseMatcher]]: + r"""Return a callable for the get phrase matcher method over gRPC. + + Gets a phrase matcher. + + Returns: + Callable[[~.GetPhraseMatcherRequest], + Awaitable[~.PhraseMatcher]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'get_phrase_matcher' not in self._stubs: + self._stubs['get_phrase_matcher'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetPhraseMatcher', + request_serializer=contact_center_insights.GetPhraseMatcherRequest.serialize, + response_deserializer=resources.PhraseMatcher.deserialize, + ) + return self._stubs['get_phrase_matcher'] + + @property + def list_phrase_matchers(self) -> Callable[ + [contact_center_insights.ListPhraseMatchersRequest], + Awaitable[contact_center_insights.ListPhraseMatchersResponse]]: + r"""Return a callable for the list phrase matchers method over gRPC. + + Lists phrase matchers. + + Returns: + Callable[[~.ListPhraseMatchersRequest], + Awaitable[~.ListPhraseMatchersResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'list_phrase_matchers' not in self._stubs: + self._stubs['list_phrase_matchers'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListPhraseMatchers', + request_serializer=contact_center_insights.ListPhraseMatchersRequest.serialize, + response_deserializer=contact_center_insights.ListPhraseMatchersResponse.deserialize, + ) + return self._stubs['list_phrase_matchers'] + + @property + def delete_phrase_matcher(self) -> Callable[ + [contact_center_insights.DeletePhraseMatcherRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete phrase matcher method over gRPC. + + Deletes a phrase matcher. + + Returns: + Callable[[~.DeletePhraseMatcherRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_phrase_matcher' not in self._stubs: + self._stubs['delete_phrase_matcher'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeletePhraseMatcher', + request_serializer=contact_center_insights.DeletePhraseMatcherRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_phrase_matcher'] + + @property + def update_phrase_matcher(self) -> Callable[ + [contact_center_insights.UpdatePhraseMatcherRequest], + Awaitable[resources.PhraseMatcher]]: + r"""Return a callable for the update phrase matcher method over gRPC. + + Updates a phrase matcher. + + Returns: + Callable[[~.UpdatePhraseMatcherRequest], + Awaitable[~.PhraseMatcher]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_phrase_matcher' not in self._stubs: + self._stubs['update_phrase_matcher'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdatePhraseMatcher', + request_serializer=contact_center_insights.UpdatePhraseMatcherRequest.serialize, + response_deserializer=resources.PhraseMatcher.deserialize, + ) + return self._stubs['update_phrase_matcher'] + + @property + def calculate_stats(self) -> Callable[ + [contact_center_insights.CalculateStatsRequest], + Awaitable[contact_center_insights.CalculateStatsResponse]]: + r"""Return a callable for the calculate stats method over gRPC. + + Gets conversation statistics. + + Returns: + Callable[[~.CalculateStatsRequest], + Awaitable[~.CalculateStatsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'calculate_stats' not in self._stubs: + self._stubs['calculate_stats'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CalculateStats', + request_serializer=contact_center_insights.CalculateStatsRequest.serialize, + response_deserializer=contact_center_insights.CalculateStatsResponse.deserialize, + ) + return self._stubs['calculate_stats'] + + @property + def get_settings(self) -> Callable[ + [contact_center_insights.GetSettingsRequest], + Awaitable[resources.Settings]]: + r"""Return a callable for the get settings method over gRPC. + + Gets project-level settings. + + Returns: + Callable[[~.GetSettingsRequest], + Awaitable[~.Settings]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'get_settings' not in self._stubs: + self._stubs['get_settings'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetSettings', + request_serializer=contact_center_insights.GetSettingsRequest.serialize, + response_deserializer=resources.Settings.deserialize, + ) + return self._stubs['get_settings'] + + @property + def update_settings(self) -> Callable[ + [contact_center_insights.UpdateSettingsRequest], + Awaitable[resources.Settings]]: + r"""Return a callable for the update settings method over gRPC. + + Updates project-level settings. + + Returns: + Callable[[~.UpdateSettingsRequest], + Awaitable[~.Settings]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_settings' not in self._stubs: + self._stubs['update_settings'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateSettings', + request_serializer=contact_center_insights.UpdateSettingsRequest.serialize, + response_deserializer=resources.Settings.deserialize, + ) + return self._stubs['update_settings'] + + @property + def create_view(self) -> Callable[ + [contact_center_insights.CreateViewRequest], + Awaitable[resources.View]]: + r"""Return a callable for the create view method over gRPC. + + Creates a view. + + Returns: + Callable[[~.CreateViewRequest], + Awaitable[~.View]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'create_view' not in self._stubs: + self._stubs['create_view'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateView', + request_serializer=contact_center_insights.CreateViewRequest.serialize, + response_deserializer=resources.View.deserialize, + ) + return self._stubs['create_view'] + + @property + def get_view(self) -> Callable[ + [contact_center_insights.GetViewRequest], + Awaitable[resources.View]]: + r"""Return a callable for the get view method over gRPC. + + Gets a view. + + Returns: + Callable[[~.GetViewRequest], + Awaitable[~.View]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'get_view' not in self._stubs: + self._stubs['get_view'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetView', + request_serializer=contact_center_insights.GetViewRequest.serialize, + response_deserializer=resources.View.deserialize, + ) + return self._stubs['get_view'] + + @property + def list_views(self) -> Callable[ + [contact_center_insights.ListViewsRequest], + Awaitable[contact_center_insights.ListViewsResponse]]: + r"""Return a callable for the list views method over gRPC. + + Lists views. + + Returns: + Callable[[~.ListViewsRequest], + Awaitable[~.ListViewsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'list_views' not in self._stubs: + self._stubs['list_views'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListViews', + request_serializer=contact_center_insights.ListViewsRequest.serialize, + response_deserializer=contact_center_insights.ListViewsResponse.deserialize, + ) + return self._stubs['list_views'] + + @property + def update_view(self) -> Callable[ + [contact_center_insights.UpdateViewRequest], + Awaitable[resources.View]]: + r"""Return a callable for the update view method over gRPC. + + Updates a view. + + Returns: + Callable[[~.UpdateViewRequest], + Awaitable[~.View]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'update_view' not in self._stubs: + self._stubs['update_view'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateView', + request_serializer=contact_center_insights.UpdateViewRequest.serialize, + response_deserializer=resources.View.deserialize, + ) + return self._stubs['update_view'] + + @property + def delete_view(self) -> Callable[ + [contact_center_insights.DeleteViewRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete view method over gRPC. + + Deletes a view. + + Returns: + Callable[[~.DeleteViewRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_view' not in self._stubs: + self._stubs['delete_view'] = self.grpc_channel.unary_unary( + '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteView', + request_serializer=contact_center_insights.DeleteViewRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_view'] + + def close(self): + return self.grpc_channel.close() + + @property + def cancel_operation( + self, + ) -> Callable[[operations_pb2.CancelOperationRequest], None]: + r"""Return a callable for the cancel_operation method over gRPC. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "cancel_operation" not in self._stubs: + self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/CancelOperation", + request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, + response_deserializer=None, + ) + return self._stubs["cancel_operation"] + + @property + def get_operation( + self, + ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: + r"""Return a callable for the get_operation method over gRPC. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_operation" not in self._stubs: + self._stubs["get_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/GetOperation", + request_serializer=operations_pb2.GetOperationRequest.SerializeToString, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["get_operation"] + + @property + def list_operations( + self, + ) -> Callable[[operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse]: + r"""Return a callable for the list_operations method over gRPC. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_operations" not in self._stubs: + self._stubs["list_operations"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/ListOperations", + request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, + response_deserializer=operations_pb2.ListOperationsResponse.FromString, + ) + return self._stubs["list_operations"] + + +__all__ = ( + 'ContactCenterInsightsGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/rest.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/rest.py new file mode 100644 index 000000000000..38233f5e5e0c --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/rest.py @@ -0,0 +1,4718 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# + +from google.auth.transport.requests import AuthorizedSession # type: ignore +import json # type: ignore +import grpc # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.api_core import exceptions as core_exceptions +from google.api_core import retry as retries +from google.api_core import rest_helpers +from google.api_core import rest_streaming +from google.api_core import path_template +from google.api_core import gapic_v1 + +from google.protobuf import json_format +from google.api_core import operations_v1 +from requests import __version__ as requests_version +import dataclasses +import re +from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union +import warnings + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + + +from google.cloud.contact_center_insights_v1.types import contact_center_insights +from google.cloud.contact_center_insights_v1.types import resources +from google.protobuf import empty_pb2 # type: ignore +from google.longrunning import operations_pb2 # type: ignore + +from .base import ContactCenterInsightsTransport, DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO + + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, + grpc_version=None, + rest_version=requests_version, +) + + +class ContactCenterInsightsRestInterceptor: + """Interceptor for ContactCenterInsights. + + Interceptors are used to manipulate requests, request metadata, and responses + in arbitrary ways. + Example use cases include: + * Logging + * Verifying requests according to service or custom semantics + * Stripping extraneous information from responses + + These use cases and more can be enabled by injecting an + instance of a custom subclass when constructing the ContactCenterInsightsRestTransport. + + .. code-block:: python + class MyCustomContactCenterInsightsInterceptor(ContactCenterInsightsRestInterceptor): + def pre_bulk_analyze_conversations(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_bulk_analyze_conversations(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_calculate_issue_model_stats(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_calculate_issue_model_stats(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_calculate_stats(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_calculate_stats(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_analysis(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_analysis(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_conversation(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_conversation(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_issue_model(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_issue_model(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_phrase_matcher(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_phrase_matcher(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_view(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_view(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_analysis(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def pre_delete_conversation(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def pre_delete_issue(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def pre_delete_issue_model(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_issue_model(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_phrase_matcher(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def pre_delete_view(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def pre_deploy_issue_model(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_deploy_issue_model(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_export_insights_data(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_export_insights_data(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_analysis(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_analysis(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_conversation(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_conversation(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_issue(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_issue(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_issue_model(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_issue_model(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_phrase_matcher(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_phrase_matcher(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_settings(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_settings(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_view(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_view(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_ingest_conversations(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_ingest_conversations(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_analyses(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_analyses(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_conversations(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_conversations(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_issue_models(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_issue_models(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_issues(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_issues(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_phrase_matchers(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_phrase_matchers(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_views(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_views(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_undeploy_issue_model(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_undeploy_issue_model(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_conversation(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_conversation(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_issue(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_issue(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_issue_model(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_issue_model(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_phrase_matcher(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_phrase_matcher(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_settings(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_settings(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_view(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_view(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_upload_conversation(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_upload_conversation(self, response): + logging.log(f"Received response: {response}") + return response + + transport = ContactCenterInsightsRestTransport(interceptor=MyCustomContactCenterInsightsInterceptor()) + client = ContactCenterInsightsClient(transport=transport) + + + """ + def pre_bulk_analyze_conversations(self, request: contact_center_insights.BulkAnalyzeConversationsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.BulkAnalyzeConversationsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for bulk_analyze_conversations + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_bulk_analyze_conversations(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for bulk_analyze_conversations + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_calculate_issue_model_stats(self, request: contact_center_insights.CalculateIssueModelStatsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.CalculateIssueModelStatsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for calculate_issue_model_stats + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_calculate_issue_model_stats(self, response: contact_center_insights.CalculateIssueModelStatsResponse) -> contact_center_insights.CalculateIssueModelStatsResponse: + """Post-rpc interceptor for calculate_issue_model_stats + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_calculate_stats(self, request: contact_center_insights.CalculateStatsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.CalculateStatsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for calculate_stats + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_calculate_stats(self, response: contact_center_insights.CalculateStatsResponse) -> contact_center_insights.CalculateStatsResponse: + """Post-rpc interceptor for calculate_stats + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_create_analysis(self, request: contact_center_insights.CreateAnalysisRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.CreateAnalysisRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for create_analysis + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_create_analysis(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for create_analysis + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_create_conversation(self, request: contact_center_insights.CreateConversationRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.CreateConversationRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for create_conversation + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_create_conversation(self, response: resources.Conversation) -> resources.Conversation: + """Post-rpc interceptor for create_conversation + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_create_issue_model(self, request: contact_center_insights.CreateIssueModelRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.CreateIssueModelRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for create_issue_model + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_create_issue_model(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for create_issue_model + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_create_phrase_matcher(self, request: contact_center_insights.CreatePhraseMatcherRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.CreatePhraseMatcherRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for create_phrase_matcher + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_create_phrase_matcher(self, response: resources.PhraseMatcher) -> resources.PhraseMatcher: + """Post-rpc interceptor for create_phrase_matcher + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_create_view(self, request: contact_center_insights.CreateViewRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.CreateViewRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for create_view + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_create_view(self, response: resources.View) -> resources.View: + """Post-rpc interceptor for create_view + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_delete_analysis(self, request: contact_center_insights.DeleteAnalysisRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.DeleteAnalysisRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for delete_analysis + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def pre_delete_conversation(self, request: contact_center_insights.DeleteConversationRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.DeleteConversationRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for delete_conversation + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def pre_delete_issue(self, request: contact_center_insights.DeleteIssueRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.DeleteIssueRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for delete_issue + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def pre_delete_issue_model(self, request: contact_center_insights.DeleteIssueModelRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.DeleteIssueModelRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for delete_issue_model + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_delete_issue_model(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_issue_model + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_delete_phrase_matcher(self, request: contact_center_insights.DeletePhraseMatcherRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.DeletePhraseMatcherRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for delete_phrase_matcher + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def pre_delete_view(self, request: contact_center_insights.DeleteViewRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.DeleteViewRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for delete_view + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def pre_deploy_issue_model(self, request: contact_center_insights.DeployIssueModelRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.DeployIssueModelRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for deploy_issue_model + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_deploy_issue_model(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for deploy_issue_model + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_export_insights_data(self, request: contact_center_insights.ExportInsightsDataRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.ExportInsightsDataRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for export_insights_data + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_export_insights_data(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for export_insights_data + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_get_analysis(self, request: contact_center_insights.GetAnalysisRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.GetAnalysisRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_analysis + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_get_analysis(self, response: resources.Analysis) -> resources.Analysis: + """Post-rpc interceptor for get_analysis + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_get_conversation(self, request: contact_center_insights.GetConversationRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.GetConversationRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_conversation + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_get_conversation(self, response: resources.Conversation) -> resources.Conversation: + """Post-rpc interceptor for get_conversation + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_get_issue(self, request: contact_center_insights.GetIssueRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.GetIssueRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_issue + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_get_issue(self, response: resources.Issue) -> resources.Issue: + """Post-rpc interceptor for get_issue + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_get_issue_model(self, request: contact_center_insights.GetIssueModelRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.GetIssueModelRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_issue_model + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_get_issue_model(self, response: resources.IssueModel) -> resources.IssueModel: + """Post-rpc interceptor for get_issue_model + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_get_phrase_matcher(self, request: contact_center_insights.GetPhraseMatcherRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.GetPhraseMatcherRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_phrase_matcher + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_get_phrase_matcher(self, response: resources.PhraseMatcher) -> resources.PhraseMatcher: + """Post-rpc interceptor for get_phrase_matcher + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_get_settings(self, request: contact_center_insights.GetSettingsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.GetSettingsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_settings + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_get_settings(self, response: resources.Settings) -> resources.Settings: + """Post-rpc interceptor for get_settings + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_get_view(self, request: contact_center_insights.GetViewRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.GetViewRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_view + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_get_view(self, response: resources.View) -> resources.View: + """Post-rpc interceptor for get_view + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_ingest_conversations(self, request: contact_center_insights.IngestConversationsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.IngestConversationsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for ingest_conversations + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_ingest_conversations(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for ingest_conversations + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_list_analyses(self, request: contact_center_insights.ListAnalysesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.ListAnalysesRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_analyses + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_list_analyses(self, response: contact_center_insights.ListAnalysesResponse) -> contact_center_insights.ListAnalysesResponse: + """Post-rpc interceptor for list_analyses + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_list_conversations(self, request: contact_center_insights.ListConversationsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.ListConversationsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_conversations + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_list_conversations(self, response: contact_center_insights.ListConversationsResponse) -> contact_center_insights.ListConversationsResponse: + """Post-rpc interceptor for list_conversations + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_list_issue_models(self, request: contact_center_insights.ListIssueModelsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.ListIssueModelsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_issue_models + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_list_issue_models(self, response: contact_center_insights.ListIssueModelsResponse) -> contact_center_insights.ListIssueModelsResponse: + """Post-rpc interceptor for list_issue_models + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_list_issues(self, request: contact_center_insights.ListIssuesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.ListIssuesRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_issues + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_list_issues(self, response: contact_center_insights.ListIssuesResponse) -> contact_center_insights.ListIssuesResponse: + """Post-rpc interceptor for list_issues + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_list_phrase_matchers(self, request: contact_center_insights.ListPhraseMatchersRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.ListPhraseMatchersRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_phrase_matchers + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_list_phrase_matchers(self, response: contact_center_insights.ListPhraseMatchersResponse) -> contact_center_insights.ListPhraseMatchersResponse: + """Post-rpc interceptor for list_phrase_matchers + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_list_views(self, request: contact_center_insights.ListViewsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.ListViewsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_views + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_list_views(self, response: contact_center_insights.ListViewsResponse) -> contact_center_insights.ListViewsResponse: + """Post-rpc interceptor for list_views + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_undeploy_issue_model(self, request: contact_center_insights.UndeployIssueModelRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.UndeployIssueModelRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for undeploy_issue_model + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_undeploy_issue_model(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for undeploy_issue_model + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_update_conversation(self, request: contact_center_insights.UpdateConversationRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.UpdateConversationRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for update_conversation + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_update_conversation(self, response: resources.Conversation) -> resources.Conversation: + """Post-rpc interceptor for update_conversation + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_update_issue(self, request: contact_center_insights.UpdateIssueRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.UpdateIssueRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for update_issue + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_update_issue(self, response: resources.Issue) -> resources.Issue: + """Post-rpc interceptor for update_issue + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_update_issue_model(self, request: contact_center_insights.UpdateIssueModelRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.UpdateIssueModelRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for update_issue_model + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_update_issue_model(self, response: resources.IssueModel) -> resources.IssueModel: + """Post-rpc interceptor for update_issue_model + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_update_phrase_matcher(self, request: contact_center_insights.UpdatePhraseMatcherRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.UpdatePhraseMatcherRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for update_phrase_matcher + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_update_phrase_matcher(self, response: resources.PhraseMatcher) -> resources.PhraseMatcher: + """Post-rpc interceptor for update_phrase_matcher + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_update_settings(self, request: contact_center_insights.UpdateSettingsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.UpdateSettingsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for update_settings + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_update_settings(self, response: resources.Settings) -> resources.Settings: + """Post-rpc interceptor for update_settings + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_update_view(self, request: contact_center_insights.UpdateViewRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.UpdateViewRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for update_view + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_update_view(self, response: resources.View) -> resources.View: + """Post-rpc interceptor for update_view + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_upload_conversation(self, request: contact_center_insights.UploadConversationRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.UploadConversationRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for upload_conversation + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_upload_conversation(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for upload_conversation + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + + def pre_cancel_operation( + self, request: operations_pb2.CancelOperationRequest, metadata: Sequence[Tuple[str, str]] + ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for cancel_operation + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_cancel_operation( + self, response: None + ) -> None: + """Post-rpc interceptor for cancel_operation + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_get_operation( + self, request: operations_pb2.GetOperationRequest, metadata: Sequence[Tuple[str, str]] + ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_operation + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_get_operation( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for get_operation + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + def pre_list_operations( + self, request: operations_pb2.ListOperationsRequest, metadata: Sequence[Tuple[str, str]] + ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_operations + + Override in a subclass to manipulate the request or metadata + before they are sent to the ContactCenterInsights server. + """ + return request, metadata + + def post_list_operations( + self, response: operations_pb2.ListOperationsResponse + ) -> operations_pb2.ListOperationsResponse: + """Post-rpc interceptor for list_operations + + Override in a subclass to manipulate the response + after it is returned by the ContactCenterInsights server but before + it is returned to user code. + """ + return response + + +@dataclasses.dataclass +class ContactCenterInsightsRestStub: + _session: AuthorizedSession + _host: str + _interceptor: ContactCenterInsightsRestInterceptor + + +class ContactCenterInsightsRestTransport(ContactCenterInsightsTransport): + """REST backend transport for ContactCenterInsights. + + An API that lets users analyze and explore their business + conversation data. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends JSON representations of protocol buffers over HTTP/1.1 + + """ + + def __init__(self, *, + host: str = 'contactcenterinsights.googleapis.com', + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + client_cert_source_for_mtls: Optional[Callable[[ + ], Tuple[bytes, bytes]]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + url_scheme: str = 'https', + interceptor: Optional[ContactCenterInsightsRestInterceptor] = None, + api_audience: Optional[str] = None, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if ``channel`` is provided. + client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client + certificate to configure mutual TLS HTTP channel. It is ignored + if ``channel`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you are developing + your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + url_scheme: the protocol scheme for the API endpoint. Normally + "https", but for testing or local servers, + "http" can be specified. + """ + # Run the base constructor + # TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc. + # TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the + # credentials object + maybe_url_match = re.match("^(?Phttp(?:s)?://)?(?P.*)$", host) + if maybe_url_match is None: + raise ValueError(f"Unexpected hostname structure: {host}") # pragma: NO COVER + + url_match_items = maybe_url_match.groupdict() + + host = f"{url_scheme}://{host}" if not url_match_items["scheme"] else host + + super().__init__( + host=host, + credentials=credentials, + client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience + ) + self._session = AuthorizedSession( + self._credentials, default_host=self.DEFAULT_HOST) + self._operations_client: Optional[operations_v1.AbstractOperationsClient] = None + if client_cert_source_for_mtls: + self._session.configure_mtls_channel(client_cert_source_for_mtls) + self._interceptor = interceptor or ContactCenterInsightsRestInterceptor() + self._prep_wrapped_messages(client_info) + + @property + def operations_client(self) -> operations_v1.AbstractOperationsClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Only create a new client if we do not already have one. + if self._operations_client is None: + http_options: Dict[str, List[Dict[str, str]]] = { + 'google.longrunning.Operations.CancelOperation': [ + { + 'method': 'post', + 'uri': '/v1/{name=projects/*/locations/*/operations/*}:cancel', + }, + ], + 'google.longrunning.Operations.GetOperation': [ + { + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/operations/*}', + }, + ], + 'google.longrunning.Operations.ListOperations': [ + { + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*}/operations', + }, + ], + } + + rest_transport = operations_v1.OperationsRestTransport( + host=self._host, + # use the credentials which are saved + credentials=self._credentials, + scopes=self._scopes, + http_options=http_options, + path_prefix="v1") + + self._operations_client = operations_v1.AbstractOperationsClient(transport=rest_transport) + + # Return the client from cache. + return self._operations_client + + class _BulkAnalyzeConversations(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("BulkAnalyzeConversations") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.BulkAnalyzeConversationsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the bulk analyze + conversations method over HTTP. + + Args: + request (~.contact_center_insights.BulkAnalyzeConversationsRequest): + The request object. The request to analyze conversations + in bulk. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/conversations:bulkAnalyze', + 'body': '*', + }, + ] + request, metadata = self._interceptor.pre_bulk_analyze_conversations(request, metadata) + pb_request = contact_center_insights.BulkAnalyzeConversationsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_bulk_analyze_conversations(resp) + return resp + + class _CalculateIssueModelStats(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("CalculateIssueModelStats") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.CalculateIssueModelStatsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> contact_center_insights.CalculateIssueModelStatsResponse: + r"""Call the calculate issue model + stats method over HTTP. + + Args: + request (~.contact_center_insights.CalculateIssueModelStatsRequest): + The request object. Request to get statistics of an issue + model. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.contact_center_insights.CalculateIssueModelStatsResponse: + Response of querying an issue model's + statistics. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{issue_model=projects/*/locations/*/issueModels/*}:calculateIssueModelStats', + }, + ] + request, metadata = self._interceptor.pre_calculate_issue_model_stats(request, metadata) + pb_request = contact_center_insights.CalculateIssueModelStatsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = contact_center_insights.CalculateIssueModelStatsResponse() + pb_resp = contact_center_insights.CalculateIssueModelStatsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_calculate_issue_model_stats(resp) + return resp + + class _CalculateStats(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("CalculateStats") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.CalculateStatsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> contact_center_insights.CalculateStatsResponse: + r"""Call the calculate stats method over HTTP. + + Args: + request (~.contact_center_insights.CalculateStatsRequest): + The request object. The request for calculating + conversation statistics. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.contact_center_insights.CalculateStatsResponse: + The response for calculating + conversation statistics. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{location=projects/*/locations/*}/conversations:calculateStats', + }, + ] + request, metadata = self._interceptor.pre_calculate_stats(request, metadata) + pb_request = contact_center_insights.CalculateStatsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = contact_center_insights.CalculateStatsResponse() + pb_resp = contact_center_insights.CalculateStatsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_calculate_stats(resp) + return resp + + class _CreateAnalysis(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("CreateAnalysis") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.CreateAnalysisRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the create analysis method over HTTP. + + Args: + request (~.contact_center_insights.CreateAnalysisRequest): + The request object. The request to create an analysis. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*/conversations/*}/analyses', + 'body': 'analysis', + }, + ] + request, metadata = self._interceptor.pre_create_analysis(request, metadata) + pb_request = contact_center_insights.CreateAnalysisRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_analysis(resp) + return resp + + class _CreateConversation(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("CreateConversation") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.CreateConversationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> resources.Conversation: + r"""Call the create conversation method over HTTP. + + Args: + request (~.contact_center_insights.CreateConversationRequest): + The request object. Request to create a conversation. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.Conversation: + The conversation resource. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/conversations', + 'body': 'conversation', + }, + ] + request, metadata = self._interceptor.pre_create_conversation(request, metadata) + pb_request = contact_center_insights.CreateConversationRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.Conversation() + pb_resp = resources.Conversation.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_conversation(resp) + return resp + + class _CreateIssueModel(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("CreateIssueModel") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.CreateIssueModelRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the create issue model method over HTTP. + + Args: + request (~.contact_center_insights.CreateIssueModelRequest): + The request object. The request to create an issue model. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/issueModels', + 'body': 'issue_model', + }, + ] + request, metadata = self._interceptor.pre_create_issue_model(request, metadata) + pb_request = contact_center_insights.CreateIssueModelRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_issue_model(resp) + return resp + + class _CreatePhraseMatcher(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("CreatePhraseMatcher") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.CreatePhraseMatcherRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> resources.PhraseMatcher: + r"""Call the create phrase matcher method over HTTP. + + Args: + request (~.contact_center_insights.CreatePhraseMatcherRequest): + The request object. Request to create a phrase matcher. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.PhraseMatcher: + The phrase matcher resource. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/phraseMatchers', + 'body': 'phrase_matcher', + }, + ] + request, metadata = self._interceptor.pre_create_phrase_matcher(request, metadata) + pb_request = contact_center_insights.CreatePhraseMatcherRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.PhraseMatcher() + pb_resp = resources.PhraseMatcher.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_phrase_matcher(resp) + return resp + + class _CreateView(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("CreateView") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.CreateViewRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> resources.View: + r"""Call the create view method over HTTP. + + Args: + request (~.contact_center_insights.CreateViewRequest): + The request object. The request to create a view. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.View: + The View resource. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/views', + 'body': 'view', + }, + ] + request, metadata = self._interceptor.pre_create_view(request, metadata) + pb_request = contact_center_insights.CreateViewRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.View() + pb_resp = resources.View.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_view(resp) + return resp + + class _DeleteAnalysis(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("DeleteAnalysis") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.DeleteAnalysisRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ): + r"""Call the delete analysis method over HTTP. + + Args: + request (~.contact_center_insights.DeleteAnalysisRequest): + The request object. The request to delete an analysis. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/conversations/*/analyses/*}', + }, + ] + request, metadata = self._interceptor.pre_delete_analysis(request, metadata) + pb_request = contact_center_insights.DeleteAnalysisRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + class _DeleteConversation(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("DeleteConversation") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.DeleteConversationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ): + r"""Call the delete conversation method over HTTP. + + Args: + request (~.contact_center_insights.DeleteConversationRequest): + The request object. The request to delete a conversation. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/conversations/*}', + }, + ] + request, metadata = self._interceptor.pre_delete_conversation(request, metadata) + pb_request = contact_center_insights.DeleteConversationRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + class _DeleteIssue(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("DeleteIssue") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.DeleteIssueRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ): + r"""Call the delete issue method over HTTP. + + Args: + request (~.contact_center_insights.DeleteIssueRequest): + The request object. The request to delete an issue. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/issueModels/*/issues/*}', + }, + ] + request, metadata = self._interceptor.pre_delete_issue(request, metadata) + pb_request = contact_center_insights.DeleteIssueRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + class _DeleteIssueModel(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("DeleteIssueModel") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.DeleteIssueModelRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the delete issue model method over HTTP. + + Args: + request (~.contact_center_insights.DeleteIssueModelRequest): + The request object. The request to delete an issue model. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/issueModels/*}', + }, + ] + request, metadata = self._interceptor.pre_delete_issue_model(request, metadata) + pb_request = contact_center_insights.DeleteIssueModelRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_issue_model(resp) + return resp + + class _DeletePhraseMatcher(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("DeletePhraseMatcher") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.DeletePhraseMatcherRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ): + r"""Call the delete phrase matcher method over HTTP. + + Args: + request (~.contact_center_insights.DeletePhraseMatcherRequest): + The request object. The request to delete a phrase + matcher. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/phraseMatchers/*}', + }, + ] + request, metadata = self._interceptor.pre_delete_phrase_matcher(request, metadata) + pb_request = contact_center_insights.DeletePhraseMatcherRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + class _DeleteView(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("DeleteView") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.DeleteViewRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ): + r"""Call the delete view method over HTTP. + + Args: + request (~.contact_center_insights.DeleteViewRequest): + The request object. The request to delete a view. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/views/*}', + }, + ] + request, metadata = self._interceptor.pre_delete_view(request, metadata) + pb_request = contact_center_insights.DeleteViewRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + class _DeployIssueModel(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("DeployIssueModel") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.DeployIssueModelRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the deploy issue model method over HTTP. + + Args: + request (~.contact_center_insights.DeployIssueModelRequest): + The request object. The request to deploy an issue model. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{name=projects/*/locations/*/issueModels/*}:deploy', + 'body': '*', + }, + ] + request, metadata = self._interceptor.pre_deploy_issue_model(request, metadata) + pb_request = contact_center_insights.DeployIssueModelRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_deploy_issue_model(resp) + return resp + + class _ExportInsightsData(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("ExportInsightsData") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.ExportInsightsDataRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the export insights data method over HTTP. + + Args: + request (~.contact_center_insights.ExportInsightsDataRequest): + The request object. The request to export insights. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/insightsdata:export', + 'body': '*', + }, + ] + request, metadata = self._interceptor.pre_export_insights_data(request, metadata) + pb_request = contact_center_insights.ExportInsightsDataRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_export_insights_data(resp) + return resp + + class _GetAnalysis(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("GetAnalysis") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.GetAnalysisRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> resources.Analysis: + r"""Call the get analysis method over HTTP. + + Args: + request (~.contact_center_insights.GetAnalysisRequest): + The request object. The request to get an analysis. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.Analysis: + The analysis resource. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/conversations/*/analyses/*}', + }, + ] + request, metadata = self._interceptor.pre_get_analysis(request, metadata) + pb_request = contact_center_insights.GetAnalysisRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.Analysis() + pb_resp = resources.Analysis.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_analysis(resp) + return resp + + class _GetConversation(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("GetConversation") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.GetConversationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> resources.Conversation: + r"""Call the get conversation method over HTTP. + + Args: + request (~.contact_center_insights.GetConversationRequest): + The request object. The request to get a conversation. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.Conversation: + The conversation resource. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/conversations/*}', + }, + ] + request, metadata = self._interceptor.pre_get_conversation(request, metadata) + pb_request = contact_center_insights.GetConversationRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.Conversation() + pb_resp = resources.Conversation.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_conversation(resp) + return resp + + class _GetIssue(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("GetIssue") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.GetIssueRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> resources.Issue: + r"""Call the get issue method over HTTP. + + Args: + request (~.contact_center_insights.GetIssueRequest): + The request object. The request to get an issue. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.Issue: + The issue resource. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/issueModels/*/issues/*}', + }, + ] + request, metadata = self._interceptor.pre_get_issue(request, metadata) + pb_request = contact_center_insights.GetIssueRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.Issue() + pb_resp = resources.Issue.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_issue(resp) + return resp + + class _GetIssueModel(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("GetIssueModel") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.GetIssueModelRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> resources.IssueModel: + r"""Call the get issue model method over HTTP. + + Args: + request (~.contact_center_insights.GetIssueModelRequest): + The request object. The request to get an issue model. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.IssueModel: + The issue model resource. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/issueModels/*}', + }, + ] + request, metadata = self._interceptor.pre_get_issue_model(request, metadata) + pb_request = contact_center_insights.GetIssueModelRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.IssueModel() + pb_resp = resources.IssueModel.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_issue_model(resp) + return resp + + class _GetPhraseMatcher(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("GetPhraseMatcher") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.GetPhraseMatcherRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> resources.PhraseMatcher: + r"""Call the get phrase matcher method over HTTP. + + Args: + request (~.contact_center_insights.GetPhraseMatcherRequest): + The request object. The request to get a a phrase + matcher. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.PhraseMatcher: + The phrase matcher resource. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/phraseMatchers/*}', + }, + ] + request, metadata = self._interceptor.pre_get_phrase_matcher(request, metadata) + pb_request = contact_center_insights.GetPhraseMatcherRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.PhraseMatcher() + pb_resp = resources.PhraseMatcher.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_phrase_matcher(resp) + return resp + + class _GetSettings(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("GetSettings") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.GetSettingsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> resources.Settings: + r"""Call the get settings method over HTTP. + + Args: + request (~.contact_center_insights.GetSettingsRequest): + The request object. The request to get project-level + settings. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.Settings: + The settings resource. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/settings}', + }, + ] + request, metadata = self._interceptor.pre_get_settings(request, metadata) + pb_request = contact_center_insights.GetSettingsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.Settings() + pb_resp = resources.Settings.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_settings(resp) + return resp + + class _GetView(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("GetView") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.GetViewRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> resources.View: + r"""Call the get view method over HTTP. + + Args: + request (~.contact_center_insights.GetViewRequest): + The request object. The request to get a view. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.View: + The View resource. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/views/*}', + }, + ] + request, metadata = self._interceptor.pre_get_view(request, metadata) + pb_request = contact_center_insights.GetViewRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.View() + pb_resp = resources.View.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_view(resp) + return resp + + class _IngestConversations(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("IngestConversations") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.IngestConversationsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the ingest conversations method over HTTP. + + Args: + request (~.contact_center_insights.IngestConversationsRequest): + The request object. The request to ingest conversations. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/conversations:ingest', + 'body': '*', + }, + ] + request, metadata = self._interceptor.pre_ingest_conversations(request, metadata) + pb_request = contact_center_insights.IngestConversationsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_ingest_conversations(resp) + return resp + + class _ListAnalyses(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("ListAnalyses") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.ListAnalysesRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> contact_center_insights.ListAnalysesResponse: + r"""Call the list analyses method over HTTP. + + Args: + request (~.contact_center_insights.ListAnalysesRequest): + The request object. The request to list analyses. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.contact_center_insights.ListAnalysesResponse: + The response to list analyses. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*/conversations/*}/analyses', + }, + ] + request, metadata = self._interceptor.pre_list_analyses(request, metadata) + pb_request = contact_center_insights.ListAnalysesRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = contact_center_insights.ListAnalysesResponse() + pb_resp = contact_center_insights.ListAnalysesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_analyses(resp) + return resp + + class _ListConversations(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("ListConversations") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.ListConversationsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> contact_center_insights.ListConversationsResponse: + r"""Call the list conversations method over HTTP. + + Args: + request (~.contact_center_insights.ListConversationsRequest): + The request object. Request to list conversations. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.contact_center_insights.ListConversationsResponse: + The response of listing + conversations. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*}/conversations', + }, + ] + request, metadata = self._interceptor.pre_list_conversations(request, metadata) + pb_request = contact_center_insights.ListConversationsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = contact_center_insights.ListConversationsResponse() + pb_resp = contact_center_insights.ListConversationsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_conversations(resp) + return resp + + class _ListIssueModels(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("ListIssueModels") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.ListIssueModelsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> contact_center_insights.ListIssueModelsResponse: + r"""Call the list issue models method over HTTP. + + Args: + request (~.contact_center_insights.ListIssueModelsRequest): + The request object. Request to list issue models. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.contact_center_insights.ListIssueModelsResponse: + The response of listing issue models. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*}/issueModels', + }, + ] + request, metadata = self._interceptor.pre_list_issue_models(request, metadata) + pb_request = contact_center_insights.ListIssueModelsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = contact_center_insights.ListIssueModelsResponse() + pb_resp = contact_center_insights.ListIssueModelsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_issue_models(resp) + return resp + + class _ListIssues(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("ListIssues") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.ListIssuesRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> contact_center_insights.ListIssuesResponse: + r"""Call the list issues method over HTTP. + + Args: + request (~.contact_center_insights.ListIssuesRequest): + The request object. Request to list issues. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.contact_center_insights.ListIssuesResponse: + The response of listing issues. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*/issueModels/*}/issues', + }, + ] + request, metadata = self._interceptor.pre_list_issues(request, metadata) + pb_request = contact_center_insights.ListIssuesRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = contact_center_insights.ListIssuesResponse() + pb_resp = contact_center_insights.ListIssuesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_issues(resp) + return resp + + class _ListPhraseMatchers(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("ListPhraseMatchers") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.ListPhraseMatchersRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> contact_center_insights.ListPhraseMatchersResponse: + r"""Call the list phrase matchers method over HTTP. + + Args: + request (~.contact_center_insights.ListPhraseMatchersRequest): + The request object. Request to list phrase matchers. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.contact_center_insights.ListPhraseMatchersResponse: + The response of listing phrase + matchers. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*}/phraseMatchers', + }, + ] + request, metadata = self._interceptor.pre_list_phrase_matchers(request, metadata) + pb_request = contact_center_insights.ListPhraseMatchersRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = contact_center_insights.ListPhraseMatchersResponse() + pb_resp = contact_center_insights.ListPhraseMatchersResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_phrase_matchers(resp) + return resp + + class _ListViews(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("ListViews") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.ListViewsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> contact_center_insights.ListViewsResponse: + r"""Call the list views method over HTTP. + + Args: + request (~.contact_center_insights.ListViewsRequest): + The request object. The request to list views. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.contact_center_insights.ListViewsResponse: + The response of listing views. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*}/views', + }, + ] + request, metadata = self._interceptor.pre_list_views(request, metadata) + pb_request = contact_center_insights.ListViewsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = contact_center_insights.ListViewsResponse() + pb_resp = contact_center_insights.ListViewsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_views(resp) + return resp + + class _UndeployIssueModel(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("UndeployIssueModel") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.UndeployIssueModelRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the undeploy issue model method over HTTP. + + Args: + request (~.contact_center_insights.UndeployIssueModelRequest): + The request object. The request to undeploy an issue + model. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{name=projects/*/locations/*/issueModels/*}:undeploy', + 'body': '*', + }, + ] + request, metadata = self._interceptor.pre_undeploy_issue_model(request, metadata) + pb_request = contact_center_insights.UndeployIssueModelRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_undeploy_issue_model(resp) + return resp + + class _UpdateConversation(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("UpdateConversation") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.UpdateConversationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> resources.Conversation: + r"""Call the update conversation method over HTTP. + + Args: + request (~.contact_center_insights.UpdateConversationRequest): + The request object. The request to update a conversation. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.Conversation: + The conversation resource. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'patch', + 'uri': '/v1/{conversation.name=projects/*/locations/*/conversations/*}', + 'body': 'conversation', + }, + ] + request, metadata = self._interceptor.pre_update_conversation(request, metadata) + pb_request = contact_center_insights.UpdateConversationRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.Conversation() + pb_resp = resources.Conversation.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_conversation(resp) + return resp + + class _UpdateIssue(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("UpdateIssue") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.UpdateIssueRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> resources.Issue: + r"""Call the update issue method over HTTP. + + Args: + request (~.contact_center_insights.UpdateIssueRequest): + The request object. The request to update an issue. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.Issue: + The issue resource. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'patch', + 'uri': '/v1/{issue.name=projects/*/locations/*/issueModels/*/issues/*}', + 'body': 'issue', + }, + ] + request, metadata = self._interceptor.pre_update_issue(request, metadata) + pb_request = contact_center_insights.UpdateIssueRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.Issue() + pb_resp = resources.Issue.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_issue(resp) + return resp + + class _UpdateIssueModel(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("UpdateIssueModel") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.UpdateIssueModelRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> resources.IssueModel: + r"""Call the update issue model method over HTTP. + + Args: + request (~.contact_center_insights.UpdateIssueModelRequest): + The request object. The request to update an issue model. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.IssueModel: + The issue model resource. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'patch', + 'uri': '/v1/{issue_model.name=projects/*/locations/*/issueModels/*}', + 'body': 'issue_model', + }, + ] + request, metadata = self._interceptor.pre_update_issue_model(request, metadata) + pb_request = contact_center_insights.UpdateIssueModelRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.IssueModel() + pb_resp = resources.IssueModel.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_issue_model(resp) + return resp + + class _UpdatePhraseMatcher(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("UpdatePhraseMatcher") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.UpdatePhraseMatcherRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> resources.PhraseMatcher: + r"""Call the update phrase matcher method over HTTP. + + Args: + request (~.contact_center_insights.UpdatePhraseMatcherRequest): + The request object. The request to update a phrase + matcher. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.PhraseMatcher: + The phrase matcher resource. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'patch', + 'uri': '/v1/{phrase_matcher.name=projects/*/locations/*/phraseMatchers/*}', + 'body': 'phrase_matcher', + }, + ] + request, metadata = self._interceptor.pre_update_phrase_matcher(request, metadata) + pb_request = contact_center_insights.UpdatePhraseMatcherRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.PhraseMatcher() + pb_resp = resources.PhraseMatcher.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_phrase_matcher(resp) + return resp + + class _UpdateSettings(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("UpdateSettings") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "updateMask" : {}, } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.UpdateSettingsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> resources.Settings: + r"""Call the update settings method over HTTP. + + Args: + request (~.contact_center_insights.UpdateSettingsRequest): + The request object. The request to update project-level + settings. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.Settings: + The settings resource. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'patch', + 'uri': '/v1/{settings.name=projects/*/locations/*/settings}', + 'body': 'settings', + }, + ] + request, metadata = self._interceptor.pre_update_settings(request, metadata) + pb_request = contact_center_insights.UpdateSettingsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.Settings() + pb_resp = resources.Settings.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_settings(resp) + return resp + + class _UpdateView(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("UpdateView") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.UpdateViewRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> resources.View: + r"""Call the update view method over HTTP. + + Args: + request (~.contact_center_insights.UpdateViewRequest): + The request object. The request to update a view. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.resources.View: + The View resource. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'patch', + 'uri': '/v1/{view.name=projects/*/locations/*/views/*}', + 'body': 'view', + }, + ] + request, metadata = self._interceptor.pre_update_view(request, metadata) + pb_request = contact_center_insights.UpdateViewRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = resources.View() + pb_resp = resources.View.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_view(resp) + return resp + + class _UploadConversation(ContactCenterInsightsRestStub): + def __hash__(self): + return hash("UploadConversation") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: contact_center_insights.UploadConversationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + r"""Call the upload conversation method over HTTP. + + Args: + request (~.contact_center_insights.UploadConversationRequest): + The request object. Request to upload a conversation. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/conversations:upload', + 'body': '*', + }, + ] + request, metadata = self._interceptor.pre_upload_conversation(request, metadata) + pb_request = contact_center_insights.UploadConversationRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_upload_conversation(resp) + return resp + + @property + def bulk_analyze_conversations(self) -> Callable[ + [contact_center_insights.BulkAnalyzeConversationsRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._BulkAnalyzeConversations(self._session, self._host, self._interceptor) # type: ignore + + @property + def calculate_issue_model_stats(self) -> Callable[ + [contact_center_insights.CalculateIssueModelStatsRequest], + contact_center_insights.CalculateIssueModelStatsResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CalculateIssueModelStats(self._session, self._host, self._interceptor) # type: ignore + + @property + def calculate_stats(self) -> Callable[ + [contact_center_insights.CalculateStatsRequest], + contact_center_insights.CalculateStatsResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CalculateStats(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_analysis(self) -> Callable[ + [contact_center_insights.CreateAnalysisRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateAnalysis(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_conversation(self) -> Callable[ + [contact_center_insights.CreateConversationRequest], + resources.Conversation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateConversation(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_issue_model(self) -> Callable[ + [contact_center_insights.CreateIssueModelRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateIssueModel(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_phrase_matcher(self) -> Callable[ + [contact_center_insights.CreatePhraseMatcherRequest], + resources.PhraseMatcher]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreatePhraseMatcher(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_view(self) -> Callable[ + [contact_center_insights.CreateViewRequest], + resources.View]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateView(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_analysis(self) -> Callable[ + [contact_center_insights.DeleteAnalysisRequest], + empty_pb2.Empty]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteAnalysis(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_conversation(self) -> Callable[ + [contact_center_insights.DeleteConversationRequest], + empty_pb2.Empty]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteConversation(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_issue(self) -> Callable[ + [contact_center_insights.DeleteIssueRequest], + empty_pb2.Empty]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteIssue(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_issue_model(self) -> Callable[ + [contact_center_insights.DeleteIssueModelRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteIssueModel(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_phrase_matcher(self) -> Callable[ + [contact_center_insights.DeletePhraseMatcherRequest], + empty_pb2.Empty]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeletePhraseMatcher(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_view(self) -> Callable[ + [contact_center_insights.DeleteViewRequest], + empty_pb2.Empty]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteView(self._session, self._host, self._interceptor) # type: ignore + + @property + def deploy_issue_model(self) -> Callable[ + [contact_center_insights.DeployIssueModelRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeployIssueModel(self._session, self._host, self._interceptor) # type: ignore + + @property + def export_insights_data(self) -> Callable[ + [contact_center_insights.ExportInsightsDataRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ExportInsightsData(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_analysis(self) -> Callable[ + [contact_center_insights.GetAnalysisRequest], + resources.Analysis]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetAnalysis(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_conversation(self) -> Callable[ + [contact_center_insights.GetConversationRequest], + resources.Conversation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetConversation(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_issue(self) -> Callable[ + [contact_center_insights.GetIssueRequest], + resources.Issue]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetIssue(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_issue_model(self) -> Callable[ + [contact_center_insights.GetIssueModelRequest], + resources.IssueModel]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetIssueModel(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_phrase_matcher(self) -> Callable[ + [contact_center_insights.GetPhraseMatcherRequest], + resources.PhraseMatcher]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetPhraseMatcher(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_settings(self) -> Callable[ + [contact_center_insights.GetSettingsRequest], + resources.Settings]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetSettings(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_view(self) -> Callable[ + [contact_center_insights.GetViewRequest], + resources.View]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetView(self._session, self._host, self._interceptor) # type: ignore + + @property + def ingest_conversations(self) -> Callable[ + [contact_center_insights.IngestConversationsRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._IngestConversations(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_analyses(self) -> Callable[ + [contact_center_insights.ListAnalysesRequest], + contact_center_insights.ListAnalysesResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListAnalyses(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_conversations(self) -> Callable[ + [contact_center_insights.ListConversationsRequest], + contact_center_insights.ListConversationsResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListConversations(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_issue_models(self) -> Callable[ + [contact_center_insights.ListIssueModelsRequest], + contact_center_insights.ListIssueModelsResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListIssueModels(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_issues(self) -> Callable[ + [contact_center_insights.ListIssuesRequest], + contact_center_insights.ListIssuesResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListIssues(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_phrase_matchers(self) -> Callable[ + [contact_center_insights.ListPhraseMatchersRequest], + contact_center_insights.ListPhraseMatchersResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListPhraseMatchers(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_views(self) -> Callable[ + [contact_center_insights.ListViewsRequest], + contact_center_insights.ListViewsResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListViews(self._session, self._host, self._interceptor) # type: ignore + + @property + def undeploy_issue_model(self) -> Callable[ + [contact_center_insights.UndeployIssueModelRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UndeployIssueModel(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_conversation(self) -> Callable[ + [contact_center_insights.UpdateConversationRequest], + resources.Conversation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateConversation(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_issue(self) -> Callable[ + [contact_center_insights.UpdateIssueRequest], + resources.Issue]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateIssue(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_issue_model(self) -> Callable[ + [contact_center_insights.UpdateIssueModelRequest], + resources.IssueModel]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateIssueModel(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_phrase_matcher(self) -> Callable[ + [contact_center_insights.UpdatePhraseMatcherRequest], + resources.PhraseMatcher]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdatePhraseMatcher(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_settings(self) -> Callable[ + [contact_center_insights.UpdateSettingsRequest], + resources.Settings]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateSettings(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_view(self) -> Callable[ + [contact_center_insights.UpdateViewRequest], + resources.View]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateView(self._session, self._host, self._interceptor) # type: ignore + + @property + def upload_conversation(self) -> Callable[ + [contact_center_insights.UploadConversationRequest], + operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UploadConversation(self._session, self._host, self._interceptor) # type: ignore + + @property + def cancel_operation(self): + return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore + + class _CancelOperation(ContactCenterInsightsRestStub): + def __call__(self, + request: operations_pb2.CancelOperationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> None: + + r"""Call the cancel operation method over HTTP. + + Args: + request (operations_pb2.CancelOperationRequest): + The request object for CancelOperation method. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{name=projects/*/locations/*/operations/*}:cancel', + }, + ] + + request, metadata = self._interceptor.pre_cancel_operation(request, metadata) + request_kwargs = json_format.MessageToDict(request) + transcoded_request = path_template.transcode( + http_options, **request_kwargs) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json.dumps(transcoded_request['query_params'])) + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + return self._interceptor.post_cancel_operation(None) + + @property + def get_operation(self): + return self._GetOperation(self._session, self._host, self._interceptor) # type: ignore + + class _GetOperation(ContactCenterInsightsRestStub): + def __call__(self, + request: operations_pb2.GetOperationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.Operation: + + r"""Call the get operation method over HTTP. + + Args: + request (operations_pb2.GetOperationRequest): + The request object for GetOperation method. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + operations_pb2.Operation: Response from GetOperation method. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/operations/*}', + }, + ] + + request, metadata = self._interceptor.pre_get_operation(request, metadata) + request_kwargs = json_format.MessageToDict(request) + transcoded_request = path_template.transcode( + http_options, **request_kwargs) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json.dumps(transcoded_request['query_params'])) + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + resp = operations_pb2.Operation() + resp = json_format.Parse(response.content.decode("utf-8"), resp) + resp = self._interceptor.post_get_operation(resp) + return resp + + @property + def list_operations(self): + return self._ListOperations(self._session, self._host, self._interceptor) # type: ignore + + class _ListOperations(ContactCenterInsightsRestStub): + def __call__(self, + request: operations_pb2.ListOperationsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> operations_pb2.ListOperationsResponse: + + r"""Call the list operations method over HTTP. + + Args: + request (operations_pb2.ListOperationsRequest): + The request object for ListOperations method. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + operations_pb2.ListOperationsResponse: Response from ListOperations method. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*}/operations', + }, + ] + + request, metadata = self._interceptor.pre_list_operations(request, metadata) + request_kwargs = json_format.MessageToDict(request) + transcoded_request = path_template.transcode( + http_options, **request_kwargs) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json.dumps(transcoded_request['query_params'])) + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + resp = operations_pb2.ListOperationsResponse() + resp = json_format.Parse(response.content.decode("utf-8"), resp) + resp = self._interceptor.post_list_operations(resp) + return resp + + @property + def kind(self) -> str: + return "rest" + + def close(self): + self._session.close() + + +__all__=( + 'ContactCenterInsightsRestTransport', +) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/__init__.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/__init__.py new file mode 100644 index 000000000000..56f174a104a2 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/__init__.py @@ -0,0 +1,232 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +from .contact_center_insights import ( + BulkAnalyzeConversationsMetadata, + BulkAnalyzeConversationsRequest, + BulkAnalyzeConversationsResponse, + CalculateIssueModelStatsRequest, + CalculateIssueModelStatsResponse, + CalculateStatsRequest, + CalculateStatsResponse, + CreateAnalysisOperationMetadata, + CreateAnalysisRequest, + CreateConversationRequest, + CreateIssueModelMetadata, + CreateIssueModelRequest, + CreatePhraseMatcherRequest, + CreateViewRequest, + DeleteAnalysisRequest, + DeleteConversationRequest, + DeleteIssueModelMetadata, + DeleteIssueModelRequest, + DeleteIssueRequest, + DeletePhraseMatcherRequest, + DeleteViewRequest, + DeployIssueModelMetadata, + DeployIssueModelRequest, + DeployIssueModelResponse, + ExportInsightsDataMetadata, + ExportInsightsDataRequest, + ExportInsightsDataResponse, + GetAnalysisRequest, + GetConversationRequest, + GetIssueModelRequest, + GetIssueRequest, + GetPhraseMatcherRequest, + GetSettingsRequest, + GetViewRequest, + IngestConversationsMetadata, + IngestConversationsRequest, + IngestConversationsResponse, + ListAnalysesRequest, + ListAnalysesResponse, + ListConversationsRequest, + ListConversationsResponse, + ListIssueModelsRequest, + ListIssueModelsResponse, + ListIssuesRequest, + ListIssuesResponse, + ListPhraseMatchersRequest, + ListPhraseMatchersResponse, + ListViewsRequest, + ListViewsResponse, + UndeployIssueModelMetadata, + UndeployIssueModelRequest, + UndeployIssueModelResponse, + UpdateConversationRequest, + UpdateIssueModelRequest, + UpdateIssueRequest, + UpdatePhraseMatcherRequest, + UpdateSettingsRequest, + UpdateViewRequest, + UploadConversationMetadata, + UploadConversationRequest, + ConversationView, +) +from .resources import ( + Analysis, + AnalysisResult, + AnnotationBoundary, + AnnotatorSelector, + AnswerFeedback, + ArticleSuggestionData, + CallAnnotation, + Conversation, + ConversationDataSource, + ConversationLevelSentiment, + ConversationParticipant, + ConversationSummarizationSuggestionData, + DialogflowIntent, + DialogflowInteractionData, + DialogflowSource, + Entity, + EntityMentionData, + ExactMatchConfig, + FaqAnswerData, + GcsSource, + HoldData, + Intent, + IntentMatchData, + InterruptionData, + Issue, + IssueAssignment, + IssueMatchData, + IssueModel, + IssueModelLabelStats, + IssueModelResult, + PhraseMatchData, + PhraseMatcher, + PhraseMatchRule, + PhraseMatchRuleConfig, + PhraseMatchRuleGroup, + RedactionConfig, + RuntimeAnnotation, + SentimentData, + Settings, + SilenceData, + SmartComposeSuggestionData, + SmartReplyData, + SpeechConfig, + View, +) + +__all__ = ( + 'BulkAnalyzeConversationsMetadata', + 'BulkAnalyzeConversationsRequest', + 'BulkAnalyzeConversationsResponse', + 'CalculateIssueModelStatsRequest', + 'CalculateIssueModelStatsResponse', + 'CalculateStatsRequest', + 'CalculateStatsResponse', + 'CreateAnalysisOperationMetadata', + 'CreateAnalysisRequest', + 'CreateConversationRequest', + 'CreateIssueModelMetadata', + 'CreateIssueModelRequest', + 'CreatePhraseMatcherRequest', + 'CreateViewRequest', + 'DeleteAnalysisRequest', + 'DeleteConversationRequest', + 'DeleteIssueModelMetadata', + 'DeleteIssueModelRequest', + 'DeleteIssueRequest', + 'DeletePhraseMatcherRequest', + 'DeleteViewRequest', + 'DeployIssueModelMetadata', + 'DeployIssueModelRequest', + 'DeployIssueModelResponse', + 'ExportInsightsDataMetadata', + 'ExportInsightsDataRequest', + 'ExportInsightsDataResponse', + 'GetAnalysisRequest', + 'GetConversationRequest', + 'GetIssueModelRequest', + 'GetIssueRequest', + 'GetPhraseMatcherRequest', + 'GetSettingsRequest', + 'GetViewRequest', + 'IngestConversationsMetadata', + 'IngestConversationsRequest', + 'IngestConversationsResponse', + 'ListAnalysesRequest', + 'ListAnalysesResponse', + 'ListConversationsRequest', + 'ListConversationsResponse', + 'ListIssueModelsRequest', + 'ListIssueModelsResponse', + 'ListIssuesRequest', + 'ListIssuesResponse', + 'ListPhraseMatchersRequest', + 'ListPhraseMatchersResponse', + 'ListViewsRequest', + 'ListViewsResponse', + 'UndeployIssueModelMetadata', + 'UndeployIssueModelRequest', + 'UndeployIssueModelResponse', + 'UpdateConversationRequest', + 'UpdateIssueModelRequest', + 'UpdateIssueRequest', + 'UpdatePhraseMatcherRequest', + 'UpdateSettingsRequest', + 'UpdateViewRequest', + 'UploadConversationMetadata', + 'UploadConversationRequest', + 'ConversationView', + 'Analysis', + 'AnalysisResult', + 'AnnotationBoundary', + 'AnnotatorSelector', + 'AnswerFeedback', + 'ArticleSuggestionData', + 'CallAnnotation', + 'Conversation', + 'ConversationDataSource', + 'ConversationLevelSentiment', + 'ConversationParticipant', + 'ConversationSummarizationSuggestionData', + 'DialogflowIntent', + 'DialogflowInteractionData', + 'DialogflowSource', + 'Entity', + 'EntityMentionData', + 'ExactMatchConfig', + 'FaqAnswerData', + 'GcsSource', + 'HoldData', + 'Intent', + 'IntentMatchData', + 'InterruptionData', + 'Issue', + 'IssueAssignment', + 'IssueMatchData', + 'IssueModel', + 'IssueModelLabelStats', + 'IssueModelResult', + 'PhraseMatchData', + 'PhraseMatcher', + 'PhraseMatchRule', + 'PhraseMatchRuleConfig', + 'PhraseMatchRuleGroup', + 'RedactionConfig', + 'RuntimeAnnotation', + 'SentimentData', + 'Settings', + 'SilenceData', + 'SmartComposeSuggestionData', + 'SmartReplyData', + 'SpeechConfig', + 'View', +) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/contact_center_insights.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/contact_center_insights.py new file mode 100644 index 000000000000..4e9c11a12f05 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/contact_center_insights.py @@ -0,0 +1,1838 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +from __future__ import annotations + +from typing import MutableMapping, MutableSequence + +import proto # type: ignore + +from google.cloud.contact_center_insights_v1.types import resources +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.contactcenterinsights.v1', + manifest={ + 'ConversationView', + 'CalculateStatsRequest', + 'CalculateStatsResponse', + 'CreateAnalysisOperationMetadata', + 'CreateConversationRequest', + 'UploadConversationRequest', + 'UploadConversationMetadata', + 'ListConversationsRequest', + 'ListConversationsResponse', + 'GetConversationRequest', + 'UpdateConversationRequest', + 'DeleteConversationRequest', + 'IngestConversationsRequest', + 'IngestConversationsMetadata', + 'IngestConversationsResponse', + 'CreateAnalysisRequest', + 'ListAnalysesRequest', + 'ListAnalysesResponse', + 'GetAnalysisRequest', + 'DeleteAnalysisRequest', + 'BulkAnalyzeConversationsRequest', + 'BulkAnalyzeConversationsMetadata', + 'BulkAnalyzeConversationsResponse', + 'ExportInsightsDataRequest', + 'ExportInsightsDataMetadata', + 'ExportInsightsDataResponse', + 'CreateIssueModelRequest', + 'CreateIssueModelMetadata', + 'UpdateIssueModelRequest', + 'ListIssueModelsRequest', + 'ListIssueModelsResponse', + 'GetIssueModelRequest', + 'DeleteIssueModelRequest', + 'DeleteIssueModelMetadata', + 'DeployIssueModelRequest', + 'DeployIssueModelResponse', + 'DeployIssueModelMetadata', + 'UndeployIssueModelRequest', + 'UndeployIssueModelResponse', + 'UndeployIssueModelMetadata', + 'GetIssueRequest', + 'ListIssuesRequest', + 'ListIssuesResponse', + 'UpdateIssueRequest', + 'DeleteIssueRequest', + 'CalculateIssueModelStatsRequest', + 'CalculateIssueModelStatsResponse', + 'CreatePhraseMatcherRequest', + 'ListPhraseMatchersRequest', + 'ListPhraseMatchersResponse', + 'GetPhraseMatcherRequest', + 'DeletePhraseMatcherRequest', + 'UpdatePhraseMatcherRequest', + 'GetSettingsRequest', + 'UpdateSettingsRequest', + 'CreateViewRequest', + 'GetViewRequest', + 'ListViewsRequest', + 'ListViewsResponse', + 'UpdateViewRequest', + 'DeleteViewRequest', + }, +) + + +class ConversationView(proto.Enum): + r"""Represents the options for viewing a conversation. + + Values: + CONVERSATION_VIEW_UNSPECIFIED (0): + The conversation view is not specified. + + - Defaults to ``FULL`` in ``GetConversationRequest``. + - Defaults to ``BASIC`` in ``ListConversationsRequest``. + FULL (2): + Populates all fields in the conversation. + BASIC (1): + Populates all fields in the conversation + except the transcript. + """ + CONVERSATION_VIEW_UNSPECIFIED = 0 + FULL = 2 + BASIC = 1 + + +class CalculateStatsRequest(proto.Message): + r"""The request for calculating conversation statistics. + + Attributes: + location (str): + Required. The location of the conversations. + filter (str): + A filter to reduce results to a specific + subset. This field is useful for getting + statistics about conversations with specific + properties. + """ + + location: str = proto.Field( + proto.STRING, + number=1, + ) + filter: str = proto.Field( + proto.STRING, + number=2, + ) + + +class CalculateStatsResponse(proto.Message): + r"""The response for calculating conversation statistics. + + Attributes: + average_duration (google.protobuf.duration_pb2.Duration): + The average duration of all conversations. + The average is calculated using only + conversations that have a time duration. + average_turn_count (int): + The average number of turns per conversation. + conversation_count (int): + The total number of conversations. + smart_highlighter_matches (MutableMapping[str, int]): + A map associating each smart highlighter + display name with its respective number of + matches in the set of conversations. + custom_highlighter_matches (MutableMapping[str, int]): + A map associating each custom highlighter + resource name with its respective number of + matches in the set of conversations. + issue_matches (MutableMapping[str, int]): + A map associating each issue resource name with its + respective number of matches in the set of conversations. + Key has the format: + ``projects//locations//issueModels//issues/`` + Deprecated, use ``issue_matches_stats`` field instead. + issue_matches_stats (MutableMapping[str, google.cloud.contact_center_insights_v1.types.IssueModelLabelStats.IssueStats]): + A map associating each issue resource name with its + respective number of matches in the set of conversations. + Key has the format: + ``projects//locations//issueModels//issues/`` + conversation_count_time_series (google.cloud.contact_center_insights_v1.types.CalculateStatsResponse.TimeSeries): + A time series representing the count of + conversations created over time that match that + requested filter criteria. + """ + + class TimeSeries(proto.Message): + r"""A time series representing conversations over time. + + Attributes: + interval_duration (google.protobuf.duration_pb2.Duration): + The duration of each interval. + points (MutableSequence[google.cloud.contact_center_insights_v1.types.CalculateStatsResponse.TimeSeries.Interval]): + An ordered list of intervals from earliest to + latest, where each interval represents the + number of conversations that transpired during + the time window. + """ + + class Interval(proto.Message): + r"""A single interval in a time series. + + Attributes: + start_time (google.protobuf.timestamp_pb2.Timestamp): + The start time of this interval. + conversation_count (int): + The number of conversations created in this + interval. + """ + + start_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + conversation_count: int = proto.Field( + proto.INT32, + number=2, + ) + + interval_duration: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=1, + message=duration_pb2.Duration, + ) + points: MutableSequence['CalculateStatsResponse.TimeSeries.Interval'] = proto.RepeatedField( + proto.MESSAGE, + number=2, + message='CalculateStatsResponse.TimeSeries.Interval', + ) + + average_duration: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=1, + message=duration_pb2.Duration, + ) + average_turn_count: int = proto.Field( + proto.INT32, + number=2, + ) + conversation_count: int = proto.Field( + proto.INT32, + number=3, + ) + smart_highlighter_matches: MutableMapping[str, int] = proto.MapField( + proto.STRING, + proto.INT32, + number=4, + ) + custom_highlighter_matches: MutableMapping[str, int] = proto.MapField( + proto.STRING, + proto.INT32, + number=5, + ) + issue_matches: MutableMapping[str, int] = proto.MapField( + proto.STRING, + proto.INT32, + number=6, + ) + issue_matches_stats: MutableMapping[str, resources.IssueModelLabelStats.IssueStats] = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=8, + message=resources.IssueModelLabelStats.IssueStats, + ) + conversation_count_time_series: TimeSeries = proto.Field( + proto.MESSAGE, + number=7, + message=TimeSeries, + ) + + +class CreateAnalysisOperationMetadata(proto.Message): + r"""Metadata for a create analysis operation. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + conversation (str): + Output only. The Conversation that this + Analysis Operation belongs to. + annotator_selector (google.cloud.contact_center_insights_v1.types.AnnotatorSelector): + Output only. The annotator selector used for + the analysis (if any). + """ + + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + conversation: str = proto.Field( + proto.STRING, + number=3, + ) + annotator_selector: resources.AnnotatorSelector = proto.Field( + proto.MESSAGE, + number=4, + message=resources.AnnotatorSelector, + ) + + +class CreateConversationRequest(proto.Message): + r"""Request to create a conversation. + + Attributes: + parent (str): + Required. The parent resource of the + conversation. + conversation (google.cloud.contact_center_insights_v1.types.Conversation): + Required. The conversation resource to + create. + conversation_id (str): + A unique ID for the new conversation. This ID will become + the final component of the conversation's resource name. If + no ID is specified, a server-generated ID will be used. + + This value should be 4-64 characters and must match the + regular expression ``^[a-z0-9-]{4,64}$``. Valid characters + are ``[a-z][0-9]-`` + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + conversation: resources.Conversation = proto.Field( + proto.MESSAGE, + number=2, + message=resources.Conversation, + ) + conversation_id: str = proto.Field( + proto.STRING, + number=3, + ) + + +class UploadConversationRequest(proto.Message): + r"""Request to upload a conversation. + + Attributes: + parent (str): + Required. The parent resource of the + conversation. + conversation (google.cloud.contact_center_insights_v1.types.Conversation): + Required. The conversation resource to + create. + conversation_id (str): + Optional. A unique ID for the new conversation. This ID will + become the final component of the conversation's resource + name. If no ID is specified, a server-generated ID will be + used. + + This value should be 4-64 characters and must match the + regular expression ``^[a-z0-9-]{4,64}$``. Valid characters + are ``[a-z][0-9]-`` + redaction_config (google.cloud.contact_center_insights_v1.types.RedactionConfig): + 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( + proto.STRING, + number=1, + ) + conversation: resources.Conversation = proto.Field( + proto.MESSAGE, + number=2, + message=resources.Conversation, + ) + conversation_id: str = proto.Field( + proto.STRING, + number=3, + ) + redaction_config: resources.RedactionConfig = proto.Field( + proto.MESSAGE, + number=4, + message=resources.RedactionConfig, + ) + speech_config: resources.SpeechConfig = proto.Field( + proto.MESSAGE, + number=11, + message=resources.SpeechConfig, + ) + + +class UploadConversationMetadata(proto.Message): + r"""The metadata for an UploadConversation operation. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + request (google.cloud.contact_center_insights_v1.types.UploadConversationRequest): + Output only. The original request. + analysis_operation (str): + Output only. The operation name for a + successfully created analysis operation, if any. + applied_redaction_config (google.cloud.contact_center_insights_v1.types.RedactionConfig): + Output only. The redaction config applied to + the uploaded conversation. + """ + + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + request: 'UploadConversationRequest' = proto.Field( + proto.MESSAGE, + number=3, + message='UploadConversationRequest', + ) + analysis_operation: str = proto.Field( + proto.STRING, + number=4, + ) + applied_redaction_config: resources.RedactionConfig = proto.Field( + proto.MESSAGE, + number=5, + message=resources.RedactionConfig, + ) + + +class ListConversationsRequest(proto.Message): + r"""Request to list conversations. + + Attributes: + parent (str): + Required. The parent resource of the + conversation. + page_size (int): + The maximum number of conversations to return + in the response. A valid page size ranges from 0 + to 1,000 inclusive. If the page size is zero or + unspecified, a default page size of 100 will be + chosen. Note that a call might return fewer + results than the requested page size. + page_token (str): + The value returned by the last + ``ListConversationsResponse``. This value indicates that + this is a continuation of a prior ``ListConversations`` call + and that the system should return the next page of data. + filter (str): + A filter to reduce results to a specific + subset. Useful for querying conversations with + specific properties. + view (google.cloud.contact_center_insights_v1.types.ConversationView): + The level of details of the conversation. Default is + ``BASIC``. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + filter: str = proto.Field( + proto.STRING, + number=4, + ) + view: 'ConversationView' = proto.Field( + proto.ENUM, + number=5, + enum='ConversationView', + ) + + +class ListConversationsResponse(proto.Message): + r"""The response of listing conversations. + + Attributes: + conversations (MutableSequence[google.cloud.contact_center_insights_v1.types.Conversation]): + The conversations that match the request. + next_page_token (str): + A token which can be sent as ``page_token`` to retrieve the + next page. If this field is set, it means there is another + page available. If it is not set, it means no other pages + are available. + """ + + @property + def raw_page(self): + return self + + conversations: MutableSequence[resources.Conversation] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.Conversation, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class GetConversationRequest(proto.Message): + r"""The request to get a conversation. + + Attributes: + name (str): + Required. The name of the conversation to + get. + view (google.cloud.contact_center_insights_v1.types.ConversationView): + The level of details of the conversation. Default is + ``FULL``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + view: 'ConversationView' = proto.Field( + proto.ENUM, + number=2, + enum='ConversationView', + ) + + +class UpdateConversationRequest(proto.Message): + r"""The request to update a conversation. + + Attributes: + conversation (google.cloud.contact_center_insights_v1.types.Conversation): + Required. The new values for the + conversation. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + """ + + conversation: resources.Conversation = proto.Field( + proto.MESSAGE, + number=1, + message=resources.Conversation, + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteConversationRequest(proto.Message): + r"""The request to delete a conversation. + + Attributes: + name (str): + Required. The name of the conversation to + delete. + force (bool): + If set to true, all of this conversation's + analyses will also be deleted. Otherwise, the + request will only succeed if the conversation + has no analyses. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + force: bool = proto.Field( + proto.BOOL, + number=2, + ) + + +class IngestConversationsRequest(proto.Message): + r"""The request to ingest conversations. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + gcs_source (google.cloud.contact_center_insights_v1.types.IngestConversationsRequest.GcsSource): + 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): + Configuration for when ``source`` contains conversation + transcripts. + + This field is a member of `oneof`_ ``object_config``. + parent (str): + Required. The parent resource for new + conversations. + conversation_config (google.cloud.contact_center_insights_v1.types.IngestConversationsRequest.ConversationConfig): + Configuration that applies to all + conversations. + """ + + class GcsSource(proto.Message): + r"""Configuration for Cloud Storage bucket sources. + + Attributes: + bucket_uri (str): + Required. The Cloud Storage bucket containing + source objects. + """ + + bucket_uri: str = proto.Field( + proto.STRING, + number=1, + ) + + class TranscriptObjectConfig(proto.Message): + r"""Configuration for processing transcript objects. + + Attributes: + medium (google.cloud.contact_center_insights_v1.types.Conversation.Medium): + Required. The medium transcript objects + represent. + """ + + medium: resources.Conversation.Medium = proto.Field( + proto.ENUM, + number=1, + enum=resources.Conversation.Medium, + ) + + class ConversationConfig(proto.Message): + r"""Configuration that applies to all conversations. + + Attributes: + agent_id (str): + An opaque, user-specified string representing + the human agent who handled the conversations. + """ + + agent_id: str = proto.Field( + proto.STRING, + number=1, + ) + + gcs_source: GcsSource = proto.Field( + proto.MESSAGE, + number=2, + oneof='source', + message=GcsSource, + ) + transcript_object_config: TranscriptObjectConfig = proto.Field( + proto.MESSAGE, + number=3, + oneof='object_config', + message=TranscriptObjectConfig, + ) + parent: str = proto.Field( + proto.STRING, + number=1, + ) + conversation_config: ConversationConfig = proto.Field( + proto.MESSAGE, + number=4, + message=ConversationConfig, + ) + + +class IngestConversationsMetadata(proto.Message): + r"""The metadata for an IngestConversations operation. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + request (google.cloud.contact_center_insights_v1.types.IngestConversationsRequest): + Output only. The original request for ingest. + partial_errors (MutableSequence[google.rpc.status_pb2.Status]): + Output only. Partial errors during ingest + operation that might cause the operation output + to be incomplete. + ingest_conversations_stats (google.cloud.contact_center_insights_v1.types.IngestConversationsMetadata.IngestConversationsStats): + Output only. Statistics for + IngestConversations operation. + """ + + class IngestConversationsStats(proto.Message): + r"""Statistics for IngestConversations operation. + + Attributes: + processed_object_count (int): + Output only. The number of objects processed + during the ingest operation. + duplicates_skipped_count (int): + Output only. The number of objects skipped + because another conversation with the same + transcript uri had already been ingested. + successful_ingest_count (int): + Output only. The number of new conversations + added during this ingest operation. + failed_ingest_count (int): + Output only. The number of objects which were unable to be + ingested due to errors. The errors are populated in the + partial_errors field. + """ + + processed_object_count: int = proto.Field( + proto.INT32, + number=1, + ) + duplicates_skipped_count: int = proto.Field( + proto.INT32, + number=2, + ) + successful_ingest_count: int = proto.Field( + proto.INT32, + number=3, + ) + failed_ingest_count: int = proto.Field( + proto.INT32, + number=4, + ) + + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + request: 'IngestConversationsRequest' = proto.Field( + proto.MESSAGE, + number=3, + message='IngestConversationsRequest', + ) + partial_errors: MutableSequence[status_pb2.Status] = proto.RepeatedField( + proto.MESSAGE, + number=4, + message=status_pb2.Status, + ) + ingest_conversations_stats: IngestConversationsStats = proto.Field( + proto.MESSAGE, + number=5, + message=IngestConversationsStats, + ) + + +class IngestConversationsResponse(proto.Message): + r"""The response to an IngestConversations operation. + """ + + +class CreateAnalysisRequest(proto.Message): + r"""The request to create an analysis. + + Attributes: + parent (str): + Required. The parent resource of the + analysis. + analysis (google.cloud.contact_center_insights_v1.types.Analysis): + Required. The analysis to create. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + analysis: resources.Analysis = proto.Field( + proto.MESSAGE, + number=2, + message=resources.Analysis, + ) + + +class ListAnalysesRequest(proto.Message): + r"""The request to list analyses. + + Attributes: + parent (str): + Required. The parent resource of the + analyses. + page_size (int): + The maximum number of analyses to return in the response. If + this value is zero, the service will select a default size. + A call might return fewer objects than requested. A + non-empty ``next_page_token`` in the response indicates that + more data is available. + page_token (str): + The value returned by the last ``ListAnalysesResponse``; + indicates that this is a continuation of a prior + ``ListAnalyses`` call and the system should return the next + page of data. + filter (str): + A filter to reduce results to a specific + subset. Useful for querying conversations with + specific properties. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + filter: str = proto.Field( + proto.STRING, + number=4, + ) + + +class ListAnalysesResponse(proto.Message): + r"""The response to list analyses. + + Attributes: + analyses (MutableSequence[google.cloud.contact_center_insights_v1.types.Analysis]): + The analyses that match the request. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + analyses: MutableSequence[resources.Analysis] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.Analysis, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class GetAnalysisRequest(proto.Message): + r"""The request to get an analysis. + + Attributes: + name (str): + Required. The name of the analysis to get. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class DeleteAnalysisRequest(proto.Message): + r"""The request to delete an analysis. + + Attributes: + name (str): + Required. The name of the analysis to delete. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class BulkAnalyzeConversationsRequest(proto.Message): + r"""The request to analyze conversations in bulk. + + Attributes: + parent (str): + Required. The parent resource to create + analyses in. + filter (str): + Required. Filter used to select the subset of + conversations to analyze. + analysis_percentage (float): + Required. Percentage of selected conversation to analyze, + between [0, 100]. + annotator_selector (google.cloud.contact_center_insights_v1.types.AnnotatorSelector): + To select the annotators to run and the + phrase matchers to use (if any). If not + specified, all annotators will be run. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + filter: str = proto.Field( + proto.STRING, + number=2, + ) + analysis_percentage: float = proto.Field( + proto.FLOAT, + number=3, + ) + annotator_selector: resources.AnnotatorSelector = proto.Field( + proto.MESSAGE, + number=8, + message=resources.AnnotatorSelector, + ) + + +class BulkAnalyzeConversationsMetadata(proto.Message): + r"""The metadata for a bulk analyze conversations operation. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + The time the operation was created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + The time the operation finished running. + request (google.cloud.contact_center_insights_v1.types.BulkAnalyzeConversationsRequest): + The original request for bulk analyze. + completed_analyses_count (int): + The number of requested analyses that have + completed successfully so far. + failed_analyses_count (int): + The number of requested analyses that have + failed so far. + total_requested_analyses_count (int): + Total number of analyses requested. Computed by the number + of conversations returned by ``filter`` multiplied by + ``analysis_percentage`` in the request. + """ + + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + request: 'BulkAnalyzeConversationsRequest' = proto.Field( + proto.MESSAGE, + number=3, + message='BulkAnalyzeConversationsRequest', + ) + completed_analyses_count: int = proto.Field( + proto.INT32, + number=4, + ) + failed_analyses_count: int = proto.Field( + proto.INT32, + number=5, + ) + total_requested_analyses_count: int = proto.Field( + proto.INT32, + number=6, + ) + + +class BulkAnalyzeConversationsResponse(proto.Message): + r"""The response for a bulk analyze conversations operation. + + Attributes: + successful_analysis_count (int): + Count of successful analyses. + failed_analysis_count (int): + Count of failed analyses. + """ + + successful_analysis_count: int = proto.Field( + proto.INT32, + number=1, + ) + failed_analysis_count: int = proto.Field( + proto.INT32, + number=2, + ) + + +class ExportInsightsDataRequest(proto.Message): + r"""The request to export insights. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + big_query_destination (google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest.BigQueryDestination): + Specified if sink is a BigQuery table. + + This field is a member of `oneof`_ ``destination``. + parent (str): + Required. The parent resource to export data + from. + filter (str): + A filter to reduce results to a specific + subset. Useful for exporting conversations with + specific properties. + kms_key (str): + A fully qualified KMS key name for BigQuery + tables protected by CMEK. Format: + + projects/{project}/locations/{location}/keyRings/{keyring}/cryptoKeys/{key}/cryptoKeyVersions/{version} + write_disposition (google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest.WriteDisposition): + Options for what to do if the destination + table already exists. + """ + class WriteDisposition(proto.Enum): + r"""Specifies the action that occurs if the destination table + already exists. + + Values: + WRITE_DISPOSITION_UNSPECIFIED (0): + Write disposition is not specified. Defaults to + WRITE_TRUNCATE. + WRITE_TRUNCATE (1): + If the table already exists, BigQuery will + overwrite the table data and use the schema from + the load. + WRITE_APPEND (2): + If the table already exists, BigQuery will + append data to the table. + """ + WRITE_DISPOSITION_UNSPECIFIED = 0 + WRITE_TRUNCATE = 1 + WRITE_APPEND = 2 + + class BigQueryDestination(proto.Message): + r"""A BigQuery Table Reference. + + Attributes: + project_id (str): + A project ID or number. If specified, then + export will attempt to write data to this + project instead of the resource project. + Otherwise, the resource project will be used. + dataset (str): + Required. The name of the BigQuery dataset that the snapshot + result should be exported to. If this dataset does not + exist, the export call returns an INVALID_ARGUMENT error. + table (str): + The BigQuery table name to which the insights data should be + written. If this table does not exist, the export call + returns an INVALID_ARGUMENT error. + """ + + project_id: str = proto.Field( + proto.STRING, + number=3, + ) + dataset: str = proto.Field( + proto.STRING, + number=1, + ) + table: str = proto.Field( + proto.STRING, + number=2, + ) + + big_query_destination: BigQueryDestination = proto.Field( + proto.MESSAGE, + number=2, + oneof='destination', + message=BigQueryDestination, + ) + parent: str = proto.Field( + proto.STRING, + number=1, + ) + filter: str = proto.Field( + proto.STRING, + number=3, + ) + kms_key: str = proto.Field( + proto.STRING, + number=4, + ) + write_disposition: WriteDisposition = proto.Field( + proto.ENUM, + number=5, + enum=WriteDisposition, + ) + + +class ExportInsightsDataMetadata(proto.Message): + r"""Metadata for an export insights operation. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + request (google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest): + The original request for export. + partial_errors (MutableSequence[google.rpc.status_pb2.Status]): + Partial errors during export operation that + might cause the operation output to be + incomplete. + """ + + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + request: 'ExportInsightsDataRequest' = proto.Field( + proto.MESSAGE, + number=3, + message='ExportInsightsDataRequest', + ) + partial_errors: MutableSequence[status_pb2.Status] = proto.RepeatedField( + proto.MESSAGE, + number=4, + message=status_pb2.Status, + ) + + +class ExportInsightsDataResponse(proto.Message): + r"""Response for an export insights operation. + """ + + +class CreateIssueModelRequest(proto.Message): + r"""The request to create an issue model. + + Attributes: + parent (str): + Required. The parent resource of the issue + model. + issue_model (google.cloud.contact_center_insights_v1.types.IssueModel): + Required. The issue model to create. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + issue_model: resources.IssueModel = proto.Field( + proto.MESSAGE, + number=2, + message=resources.IssueModel, + ) + + +class CreateIssueModelMetadata(proto.Message): + r"""Metadata for creating an issue model. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + request (google.cloud.contact_center_insights_v1.types.CreateIssueModelRequest): + The original request for creation. + """ + + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + request: 'CreateIssueModelRequest' = proto.Field( + proto.MESSAGE, + number=3, + message='CreateIssueModelRequest', + ) + + +class UpdateIssueModelRequest(proto.Message): + r"""The request to update an issue model. + + Attributes: + issue_model (google.cloud.contact_center_insights_v1.types.IssueModel): + Required. The new values for the issue model. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + """ + + issue_model: resources.IssueModel = proto.Field( + proto.MESSAGE, + number=1, + message=resources.IssueModel, + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class ListIssueModelsRequest(proto.Message): + r"""Request to list issue models. + + Attributes: + parent (str): + Required. The parent resource of the issue + model. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListIssueModelsResponse(proto.Message): + r"""The response of listing issue models. + + Attributes: + issue_models (MutableSequence[google.cloud.contact_center_insights_v1.types.IssueModel]): + The issue models that match the request. + """ + + issue_models: MutableSequence[resources.IssueModel] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.IssueModel, + ) + + +class GetIssueModelRequest(proto.Message): + r"""The request to get an issue model. + + Attributes: + name (str): + Required. The name of the issue model to get. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class DeleteIssueModelRequest(proto.Message): + r"""The request to delete an issue model. + + Attributes: + name (str): + Required. The name of the issue model to + delete. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class DeleteIssueModelMetadata(proto.Message): + r"""Metadata for deleting an issue model. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + request (google.cloud.contact_center_insights_v1.types.DeleteIssueModelRequest): + The original request for deletion. + """ + + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + request: 'DeleteIssueModelRequest' = proto.Field( + proto.MESSAGE, + number=3, + message='DeleteIssueModelRequest', + ) + + +class DeployIssueModelRequest(proto.Message): + r"""The request to deploy an issue model. + + Attributes: + name (str): + Required. The issue model to deploy. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class DeployIssueModelResponse(proto.Message): + r"""The response to deploy an issue model. + """ + + +class DeployIssueModelMetadata(proto.Message): + r"""Metadata for deploying an issue model. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + request (google.cloud.contact_center_insights_v1.types.DeployIssueModelRequest): + The original request for deployment. + """ + + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + request: 'DeployIssueModelRequest' = proto.Field( + proto.MESSAGE, + number=3, + message='DeployIssueModelRequest', + ) + + +class UndeployIssueModelRequest(proto.Message): + r"""The request to undeploy an issue model. + + Attributes: + name (str): + Required. The issue model to undeploy. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class UndeployIssueModelResponse(proto.Message): + r"""The response to undeploy an issue model. + """ + + +class UndeployIssueModelMetadata(proto.Message): + r"""Metadata for undeploying an issue model. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + request (google.cloud.contact_center_insights_v1.types.UndeployIssueModelRequest): + The original request for undeployment. + """ + + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + request: 'UndeployIssueModelRequest' = proto.Field( + proto.MESSAGE, + number=3, + message='UndeployIssueModelRequest', + ) + + +class GetIssueRequest(proto.Message): + r"""The request to get an issue. + + Attributes: + name (str): + Required. The name of the issue to get. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListIssuesRequest(proto.Message): + r"""Request to list issues. + + Attributes: + parent (str): + Required. The parent resource of the issue. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListIssuesResponse(proto.Message): + r"""The response of listing issues. + + Attributes: + issues (MutableSequence[google.cloud.contact_center_insights_v1.types.Issue]): + The issues that match the request. + """ + + issues: MutableSequence[resources.Issue] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.Issue, + ) + + +class UpdateIssueRequest(proto.Message): + r"""The request to update an issue. + + Attributes: + issue (google.cloud.contact_center_insights_v1.types.Issue): + Required. The new values for the issue. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + """ + + issue: resources.Issue = proto.Field( + proto.MESSAGE, + number=1, + message=resources.Issue, + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteIssueRequest(proto.Message): + r"""The request to delete an issue. + + Attributes: + name (str): + Required. The name of the issue to delete. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CalculateIssueModelStatsRequest(proto.Message): + r"""Request to get statistics of an issue model. + + Attributes: + issue_model (str): + Required. The resource name of the issue + model to query against. + """ + + issue_model: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CalculateIssueModelStatsResponse(proto.Message): + r"""Response of querying an issue model's statistics. + + Attributes: + current_stats (google.cloud.contact_center_insights_v1.types.IssueModelLabelStats): + The latest label statistics for the queried + issue model. Includes results on both training + data and data labeled after deployment. + """ + + current_stats: resources.IssueModelLabelStats = proto.Field( + proto.MESSAGE, + number=4, + message=resources.IssueModelLabelStats, + ) + + +class CreatePhraseMatcherRequest(proto.Message): + r"""Request to create a phrase matcher. + + Attributes: + parent (str): + Required. The parent resource of the phrase matcher. + Required. The location to create a phrase matcher for. + Format: ``projects//locations/`` or + ``projects//locations/`` + phrase_matcher (google.cloud.contact_center_insights_v1.types.PhraseMatcher): + Required. The phrase matcher resource to + create. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + phrase_matcher: resources.PhraseMatcher = proto.Field( + proto.MESSAGE, + number=2, + message=resources.PhraseMatcher, + ) + + +class ListPhraseMatchersRequest(proto.Message): + r"""Request to list phrase matchers. + + Attributes: + parent (str): + Required. The parent resource of the phrase + matcher. + page_size (int): + The maximum number of phrase matchers to return in the + response. If this value is zero, the service will select a + default size. A call might return fewer objects than + requested. A non-empty ``next_page_token`` in the response + indicates that more data is available. + page_token (str): + The value returned by the last + ``ListPhraseMatchersResponse``. This value indicates that + this is a continuation of a prior ``ListPhraseMatchers`` + call and that the system should return the next page of + data. + filter (str): + A filter to reduce results to a specific + subset. Useful for querying phrase matchers with + specific properties. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + filter: str = proto.Field( + proto.STRING, + number=4, + ) + + +class ListPhraseMatchersResponse(proto.Message): + r"""The response of listing phrase matchers. + + Attributes: + phrase_matchers (MutableSequence[google.cloud.contact_center_insights_v1.types.PhraseMatcher]): + The phrase matchers that match the request. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + phrase_matchers: MutableSequence[resources.PhraseMatcher] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.PhraseMatcher, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class GetPhraseMatcherRequest(proto.Message): + r"""The request to get a a phrase matcher. + + Attributes: + name (str): + Required. The name of the phrase matcher to + get. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class DeletePhraseMatcherRequest(proto.Message): + r"""The request to delete a phrase matcher. + + Attributes: + name (str): + Required. The name of the phrase matcher to + delete. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdatePhraseMatcherRequest(proto.Message): + r"""The request to update a phrase matcher. + + Attributes: + phrase_matcher (google.cloud.contact_center_insights_v1.types.PhraseMatcher): + Required. The new values for the phrase + matcher. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + """ + + phrase_matcher: resources.PhraseMatcher = proto.Field( + proto.MESSAGE, + number=1, + message=resources.PhraseMatcher, + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class GetSettingsRequest(proto.Message): + r"""The request to get project-level settings. + + Attributes: + name (str): + Required. The name of the settings resource + to get. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateSettingsRequest(proto.Message): + r"""The request to update project-level settings. + + Attributes: + settings (google.cloud.contact_center_insights_v1.types.Settings): + Required. The new settings values. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The list of fields to be updated. + """ + + settings: resources.Settings = proto.Field( + proto.MESSAGE, + number=1, + message=resources.Settings, + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class CreateViewRequest(proto.Message): + r"""The request to create a view. + + Attributes: + parent (str): + Required. The parent resource of the view. Required. The + location to create a view for. Format: + ``projects//locations/`` or + ``projects//locations/`` + view (google.cloud.contact_center_insights_v1.types.View): + Required. The view resource to create. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + view: resources.View = proto.Field( + proto.MESSAGE, + number=2, + message=resources.View, + ) + + +class GetViewRequest(proto.Message): + r"""The request to get a view. + + Attributes: + name (str): + Required. The name of the view to get. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListViewsRequest(proto.Message): + r"""The request to list views. + + Attributes: + parent (str): + Required. The parent resource of the views. + page_size (int): + The maximum number of views to return in the response. If + this value is zero, the service will select a default size. + A call may return fewer objects than requested. A non-empty + ``next_page_token`` in the response indicates that more data + is available. + page_token (str): + The value returned by the last ``ListViewsResponse``; + indicates that this is a continuation of a prior + ``ListViews`` call and the system should return the next + page of data. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + + +class ListViewsResponse(proto.Message): + r"""The response of listing views. + + Attributes: + views (MutableSequence[google.cloud.contact_center_insights_v1.types.View]): + The views that match the request. + next_page_token (str): + A token, which can be sent as ``page_token`` to retrieve the + next page. If this field is omitted, there are no subsequent + pages. + """ + + @property + def raw_page(self): + return self + + views: MutableSequence[resources.View] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=resources.View, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class UpdateViewRequest(proto.Message): + r"""The request to update a view. + + Attributes: + view (google.cloud.contact_center_insights_v1.types.View): + Required. The new view. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + """ + + view: resources.View = proto.Field( + proto.MESSAGE, + number=1, + message=resources.View, + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteViewRequest(proto.Message): + r"""The request to delete a view. + + Attributes: + name (str): + Required. The name of the view to delete. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/resources.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/resources.py new file mode 100644 index 000000000000..4ac5858f06cd --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/resources.py @@ -0,0 +1,2539 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +from __future__ import annotations + +from typing import MutableMapping, MutableSequence + +import proto # type: ignore + +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.contactcenterinsights.v1', + manifest={ + 'Conversation', + 'Analysis', + 'ConversationDataSource', + 'GcsSource', + 'DialogflowSource', + 'AnalysisResult', + 'IssueModelResult', + 'ConversationLevelSentiment', + 'IssueAssignment', + 'CallAnnotation', + 'AnnotationBoundary', + 'Entity', + 'Intent', + 'PhraseMatchData', + 'DialogflowIntent', + 'InterruptionData', + 'SilenceData', + 'HoldData', + 'EntityMentionData', + 'IntentMatchData', + 'SentimentData', + 'IssueMatchData', + 'IssueModel', + 'Issue', + 'IssueModelLabelStats', + 'PhraseMatcher', + 'PhraseMatchRuleGroup', + 'PhraseMatchRule', + 'PhraseMatchRuleConfig', + 'ExactMatchConfig', + 'Settings', + 'RedactionConfig', + 'SpeechConfig', + 'RuntimeAnnotation', + 'AnswerFeedback', + 'ArticleSuggestionData', + 'FaqAnswerData', + 'SmartReplyData', + 'SmartComposeSuggestionData', + 'DialogflowInteractionData', + 'ConversationSummarizationSuggestionData', + 'ConversationParticipant', + 'View', + 'AnnotatorSelector', + }, +) + + +class Conversation(proto.Message): + r"""The conversation resource. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + call_metadata (google.cloud.contact_center_insights_v1.types.Conversation.CallMetadata): + Call-specific metadata. + + This field is a member of `oneof`_ ``metadata``. + expire_time (google.protobuf.timestamp_pb2.Timestamp): + The time at which this conversation should + expire. After this time, the conversation data + and any associated analyses will be deleted. + + This field is a member of `oneof`_ ``expiration``. + ttl (google.protobuf.duration_pb2.Duration): + Input only. The TTL for this resource. If + specified, then this TTL will be used to + calculate the expire time. + + This field is a member of `oneof`_ ``expiration``. + name (str): + Immutable. The resource name of the + conversation. Format: + + projects/{project}/locations/{location}/conversations/{conversation} + data_source (google.cloud.contact_center_insights_v1.types.ConversationDataSource): + The source of the audio and transcription for + the conversation. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which the + conversation was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The most recent time at which + the conversation was updated. + start_time (google.protobuf.timestamp_pb2.Timestamp): + The time at which the conversation started. + language_code (str): + A user-specified language code for the + conversation. + agent_id (str): + An opaque, user-specified string representing + the human agent who handled the conversation. + labels (MutableMapping[str, str]): + A map for the user to specify any custom + fields. A maximum of 20 labels per conversation + is allowed, with a maximum of 256 characters per + entry. + transcript (google.cloud.contact_center_insights_v1.types.Conversation.Transcript): + Output only. The conversation transcript. + medium (google.cloud.contact_center_insights_v1.types.Conversation.Medium): + Immutable. The conversation medium, if unspecified will + default to PHONE_CALL. + duration (google.protobuf.duration_pb2.Duration): + Output only. The duration of the + conversation. + turn_count (int): + Output only. The number of turns in the + conversation. + latest_analysis (google.cloud.contact_center_insights_v1.types.Analysis): + Output only. The conversation's latest + analysis, if one exists. + latest_summary (google.cloud.contact_center_insights_v1.types.ConversationSummarizationSuggestionData): + Output only. Latest summary of the + conversation. + runtime_annotations (MutableSequence[google.cloud.contact_center_insights_v1.types.RuntimeAnnotation]): + Output only. The annotations that were + generated during the customer and agent + interaction. + dialogflow_intents (MutableMapping[str, google.cloud.contact_center_insights_v1.types.DialogflowIntent]): + Output only. All the matched Dialogflow + intents in the call. The key corresponds to a + Dialogflow intent, format: + + projects/{project}/agent/{agent}/intents/{intent} + obfuscated_user_id (str): + Obfuscated user ID which the customer sent to + us. + """ + class Medium(proto.Enum): + r"""Possible media for the conversation. + + Values: + MEDIUM_UNSPECIFIED (0): + Default value, if unspecified will default to PHONE_CALL. + PHONE_CALL (1): + The format for conversations that took place + over the phone. + CHAT (2): + The format for conversations that took place + over chat. + """ + MEDIUM_UNSPECIFIED = 0 + PHONE_CALL = 1 + CHAT = 2 + + class CallMetadata(proto.Message): + r"""Call-specific metadata. + + Attributes: + customer_channel (int): + The audio channel that contains the customer. + agent_channel (int): + The audio channel that contains the agent. + """ + + customer_channel: int = proto.Field( + proto.INT32, + number=1, + ) + agent_channel: int = proto.Field( + proto.INT32, + number=2, + ) + + class Transcript(proto.Message): + r"""A message representing the transcript of a conversation. + + Attributes: + transcript_segments (MutableSequence[google.cloud.contact_center_insights_v1.types.Conversation.Transcript.TranscriptSegment]): + A list of sequential transcript segments that + comprise the conversation. + """ + + class TranscriptSegment(proto.Message): + r"""A segment of a full transcript. + + Attributes: + message_time (google.protobuf.timestamp_pb2.Timestamp): + The time that the message occurred, if + provided. + text (str): + The text of this segment. + confidence (float): + A confidence estimate between 0.0 and 1.0 of + the fidelity of this segment. A default value of + 0.0 indicates that the value is unset. + words (MutableSequence[google.cloud.contact_center_insights_v1.types.Conversation.Transcript.TranscriptSegment.WordInfo]): + A list of the word-specific information for + each word in the segment. + language_code (str): + The language code of this segment as a + `BCP-47 `__ + language tag. Example: "en-US". + channel_tag (int): + For conversations derived from multi-channel + audio, this is the channel number corresponding + to the audio from that channel. For + audioChannelCount = N, its output values can + range from '1' to 'N'. A channel tag of 0 + indicates that the audio is mono. + segment_participant (google.cloud.contact_center_insights_v1.types.ConversationParticipant): + The participant of this segment. + dialogflow_segment_metadata (google.cloud.contact_center_insights_v1.types.Conversation.Transcript.TranscriptSegment.DialogflowSegmentMetadata): + CCAI metadata relating to the current + transcript segment. + sentiment (google.cloud.contact_center_insights_v1.types.SentimentData): + The sentiment for this transcript segment. + """ + + class WordInfo(proto.Message): + r"""Word-level info for words in a transcript. + + Attributes: + start_offset (google.protobuf.duration_pb2.Duration): + Time offset of the start of this word + relative to the beginning of the total + conversation. + end_offset (google.protobuf.duration_pb2.Duration): + Time offset of the end of this word relative + to the beginning of the total conversation. + word (str): + The word itself. Includes punctuation marks + that surround the word. + confidence (float): + A confidence estimate between 0.0 and 1.0 of + the fidelity of this word. A default value of + 0.0 indicates that the value is unset. + """ + + start_offset: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=1, + message=duration_pb2.Duration, + ) + end_offset: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=2, + message=duration_pb2.Duration, + ) + word: str = proto.Field( + proto.STRING, + number=3, + ) + confidence: float = proto.Field( + proto.FLOAT, + number=4, + ) + + class DialogflowSegmentMetadata(proto.Message): + r"""Metadata from Dialogflow relating to the current transcript + segment. + + Attributes: + smart_reply_allowlist_covered (bool): + Whether the transcript segment was covered + under the configured smart reply allowlist in + Agent Assist. + """ + + smart_reply_allowlist_covered: bool = proto.Field( + proto.BOOL, + number=1, + ) + + message_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + text: str = proto.Field( + proto.STRING, + number=1, + ) + confidence: float = proto.Field( + proto.FLOAT, + number=2, + ) + words: MutableSequence['Conversation.Transcript.TranscriptSegment.WordInfo'] = proto.RepeatedField( + proto.MESSAGE, + number=3, + message='Conversation.Transcript.TranscriptSegment.WordInfo', + ) + language_code: str = proto.Field( + proto.STRING, + number=4, + ) + channel_tag: int = proto.Field( + proto.INT32, + number=5, + ) + segment_participant: 'ConversationParticipant' = proto.Field( + proto.MESSAGE, + number=9, + message='ConversationParticipant', + ) + dialogflow_segment_metadata: 'Conversation.Transcript.TranscriptSegment.DialogflowSegmentMetadata' = proto.Field( + proto.MESSAGE, + number=10, + message='Conversation.Transcript.TranscriptSegment.DialogflowSegmentMetadata', + ) + sentiment: 'SentimentData' = proto.Field( + proto.MESSAGE, + number=11, + message='SentimentData', + ) + + transcript_segments: MutableSequence['Conversation.Transcript.TranscriptSegment'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='Conversation.Transcript.TranscriptSegment', + ) + + call_metadata: CallMetadata = proto.Field( + proto.MESSAGE, + number=7, + oneof='metadata', + message=CallMetadata, + ) + expire_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=15, + oneof='expiration', + message=timestamp_pb2.Timestamp, + ) + ttl: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=16, + oneof='expiration', + message=duration_pb2.Duration, + ) + name: str = proto.Field( + proto.STRING, + number=1, + ) + data_source: 'ConversationDataSource' = proto.Field( + proto.MESSAGE, + number=2, + message='ConversationDataSource', + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + start_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=17, + message=timestamp_pb2.Timestamp, + ) + language_code: str = proto.Field( + proto.STRING, + number=14, + ) + agent_id: str = proto.Field( + proto.STRING, + number=5, + ) + labels: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=6, + ) + transcript: Transcript = proto.Field( + proto.MESSAGE, + number=8, + message=Transcript, + ) + medium: Medium = proto.Field( + proto.ENUM, + number=9, + enum=Medium, + ) + duration: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=10, + message=duration_pb2.Duration, + ) + turn_count: int = proto.Field( + proto.INT32, + number=11, + ) + latest_analysis: 'Analysis' = proto.Field( + proto.MESSAGE, + number=12, + message='Analysis', + ) + latest_summary: 'ConversationSummarizationSuggestionData' = proto.Field( + proto.MESSAGE, + number=20, + message='ConversationSummarizationSuggestionData', + ) + runtime_annotations: MutableSequence['RuntimeAnnotation'] = proto.RepeatedField( + proto.MESSAGE, + number=13, + message='RuntimeAnnotation', + ) + dialogflow_intents: MutableMapping[str, 'DialogflowIntent'] = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=18, + message='DialogflowIntent', + ) + obfuscated_user_id: str = proto.Field( + proto.STRING, + number=21, + ) + + +class Analysis(proto.Message): + r"""The analysis resource. + + Attributes: + name (str): + Immutable. The resource name of the analysis. + Format: + + projects/{project}/locations/{location}/conversations/{conversation}/analyses/{analysis} + request_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which the analysis + was requested. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which the analysis + was created, which occurs when the long-running + operation completes. + analysis_result (google.cloud.contact_center_insights_v1.types.AnalysisResult): + Output only. The result of the analysis, + which is populated when the analysis finishes. + annotator_selector (google.cloud.contact_center_insights_v1.types.AnnotatorSelector): + To select the annotators to run and the + phrase matchers to use (if any). If not + specified, all annotators will be run. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + request_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + analysis_result: 'AnalysisResult' = proto.Field( + proto.MESSAGE, + number=7, + message='AnalysisResult', + ) + annotator_selector: 'AnnotatorSelector' = proto.Field( + proto.MESSAGE, + number=8, + message='AnnotatorSelector', + ) + + +class ConversationDataSource(proto.Message): + r"""The conversation source, which is a combination of transcript + and audio. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + gcs_source (google.cloud.contact_center_insights_v1.types.GcsSource): + A Cloud Storage location specification for + the audio and transcript. + + This field is a member of `oneof`_ ``source``. + dialogflow_source (google.cloud.contact_center_insights_v1.types.DialogflowSource): + The source when the conversation comes from + Dialogflow. + + This field is a member of `oneof`_ ``source``. + """ + + gcs_source: 'GcsSource' = proto.Field( + proto.MESSAGE, + number=1, + oneof='source', + message='GcsSource', + ) + dialogflow_source: 'DialogflowSource' = proto.Field( + proto.MESSAGE, + number=3, + oneof='source', + message='DialogflowSource', + ) + + +class GcsSource(proto.Message): + r"""A Cloud Storage source of conversation data. + + Attributes: + audio_uri (str): + Cloud Storage URI that points to a file that + contains the conversation audio. + transcript_uri (str): + Immutable. Cloud Storage URI that points to a + file that contains the conversation transcript. + """ + + audio_uri: str = proto.Field( + proto.STRING, + number=1, + ) + transcript_uri: str = proto.Field( + proto.STRING, + number=2, + ) + + +class DialogflowSource(proto.Message): + r"""A Dialogflow source of conversation data. + + Attributes: + dialogflow_conversation (str): + Output only. The name of the Dialogflow + conversation that this conversation resource is + derived from. Format: + + projects/{project}/locations/{location}/conversations/{conversation} + audio_uri (str): + Cloud Storage URI that points to a file that + contains the conversation audio. + """ + + dialogflow_conversation: str = proto.Field( + proto.STRING, + number=1, + ) + audio_uri: str = proto.Field( + proto.STRING, + number=3, + ) + + +class AnalysisResult(proto.Message): + r"""The result of an analysis. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + call_analysis_metadata (google.cloud.contact_center_insights_v1.types.AnalysisResult.CallAnalysisMetadata): + Call-specific metadata created by the + analysis. + + This field is a member of `oneof`_ ``metadata``. + end_time (google.protobuf.timestamp_pb2.Timestamp): + The time at which the analysis ended. + """ + + class CallAnalysisMetadata(proto.Message): + r"""Call-specific metadata created during analysis. + + Attributes: + annotations (MutableSequence[google.cloud.contact_center_insights_v1.types.CallAnnotation]): + A list of call annotations that apply to this + call. + entities (MutableMapping[str, google.cloud.contact_center_insights_v1.types.Entity]): + All the entities in the call. + sentiments (MutableSequence[google.cloud.contact_center_insights_v1.types.ConversationLevelSentiment]): + Overall conversation-level sentiment for each + channel of the call. + intents (MutableMapping[str, google.cloud.contact_center_insights_v1.types.Intent]): + All the matched intents in the call. + phrase_matchers (MutableMapping[str, google.cloud.contact_center_insights_v1.types.PhraseMatchData]): + All the matched phrase matchers in the call. + issue_model_result (google.cloud.contact_center_insights_v1.types.IssueModelResult): + Overall conversation-level issue modeling + result. + """ + + annotations: MutableSequence['CallAnnotation'] = proto.RepeatedField( + proto.MESSAGE, + number=2, + message='CallAnnotation', + ) + entities: MutableMapping[str, 'Entity'] = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=3, + message='Entity', + ) + sentiments: MutableSequence['ConversationLevelSentiment'] = proto.RepeatedField( + proto.MESSAGE, + number=4, + message='ConversationLevelSentiment', + ) + intents: MutableMapping[str, 'Intent'] = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=6, + message='Intent', + ) + phrase_matchers: MutableMapping[str, 'PhraseMatchData'] = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=7, + message='PhraseMatchData', + ) + issue_model_result: 'IssueModelResult' = proto.Field( + proto.MESSAGE, + number=8, + message='IssueModelResult', + ) + + call_analysis_metadata: CallAnalysisMetadata = proto.Field( + proto.MESSAGE, + number=2, + oneof='metadata', + message=CallAnalysisMetadata, + ) + end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + + +class IssueModelResult(proto.Message): + r"""Issue Modeling result on a conversation. + + Attributes: + issue_model (str): + Issue model that generates the result. Format: + projects/{project}/locations/{location}/issueModels/{issue_model} + issues (MutableSequence[google.cloud.contact_center_insights_v1.types.IssueAssignment]): + All the matched issues. + """ + + issue_model: str = proto.Field( + proto.STRING, + number=1, + ) + issues: MutableSequence['IssueAssignment'] = proto.RepeatedField( + proto.MESSAGE, + number=2, + message='IssueAssignment', + ) + + +class ConversationLevelSentiment(proto.Message): + r"""One channel of conversation-level sentiment data. + + Attributes: + channel_tag (int): + The channel of the audio that the data + applies to. + sentiment_data (google.cloud.contact_center_insights_v1.types.SentimentData): + Data specifying sentiment. + """ + + channel_tag: int = proto.Field( + proto.INT32, + number=1, + ) + sentiment_data: 'SentimentData' = proto.Field( + proto.MESSAGE, + number=2, + message='SentimentData', + ) + + +class IssueAssignment(proto.Message): + r"""Information about the issue. + + Attributes: + issue (str): + Resource name of the assigned issue. + score (float): + Score indicating the likelihood of the issue assignment. + currently bounded on [0,1]. + display_name (str): + Immutable. Display name of the assigned + issue. This field is set at time of analyis and + immutable since then. + """ + + issue: str = proto.Field( + proto.STRING, + number=1, + ) + score: float = proto.Field( + proto.DOUBLE, + number=2, + ) + display_name: str = proto.Field( + proto.STRING, + number=3, + ) + + +class CallAnnotation(proto.Message): + r"""A piece of metadata that applies to a window of a call. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + interruption_data (google.cloud.contact_center_insights_v1.types.InterruptionData): + Data specifying an interruption. + + This field is a member of `oneof`_ ``data``. + sentiment_data (google.cloud.contact_center_insights_v1.types.SentimentData): + Data specifying sentiment. + + This field is a member of `oneof`_ ``data``. + silence_data (google.cloud.contact_center_insights_v1.types.SilenceData): + Data specifying silence. + + This field is a member of `oneof`_ ``data``. + hold_data (google.cloud.contact_center_insights_v1.types.HoldData): + Data specifying a hold. + + This field is a member of `oneof`_ ``data``. + entity_mention_data (google.cloud.contact_center_insights_v1.types.EntityMentionData): + Data specifying an entity mention. + + This field is a member of `oneof`_ ``data``. + intent_match_data (google.cloud.contact_center_insights_v1.types.IntentMatchData): + Data specifying an intent match. + + This field is a member of `oneof`_ ``data``. + phrase_match_data (google.cloud.contact_center_insights_v1.types.PhraseMatchData): + Data specifying a phrase match. + + This field is a member of `oneof`_ ``data``. + issue_match_data (google.cloud.contact_center_insights_v1.types.IssueMatchData): + Data specifying an issue match. + + This field is a member of `oneof`_ ``data``. + channel_tag (int): + The channel of the audio where the annotation + occurs. For single-channel audio, this field is + not populated. + annotation_start_boundary (google.cloud.contact_center_insights_v1.types.AnnotationBoundary): + The boundary in the conversation where the + annotation starts, inclusive. + annotation_end_boundary (google.cloud.contact_center_insights_v1.types.AnnotationBoundary): + The boundary in the conversation where the + annotation ends, inclusive. + """ + + interruption_data: 'InterruptionData' = proto.Field( + proto.MESSAGE, + number=10, + oneof='data', + message='InterruptionData', + ) + sentiment_data: 'SentimentData' = proto.Field( + proto.MESSAGE, + number=11, + oneof='data', + message='SentimentData', + ) + silence_data: 'SilenceData' = proto.Field( + proto.MESSAGE, + number=12, + oneof='data', + message='SilenceData', + ) + hold_data: 'HoldData' = proto.Field( + proto.MESSAGE, + number=13, + oneof='data', + message='HoldData', + ) + entity_mention_data: 'EntityMentionData' = proto.Field( + proto.MESSAGE, + number=15, + oneof='data', + message='EntityMentionData', + ) + intent_match_data: 'IntentMatchData' = proto.Field( + proto.MESSAGE, + number=16, + oneof='data', + message='IntentMatchData', + ) + phrase_match_data: 'PhraseMatchData' = proto.Field( + proto.MESSAGE, + number=17, + oneof='data', + message='PhraseMatchData', + ) + issue_match_data: 'IssueMatchData' = proto.Field( + proto.MESSAGE, + number=18, + oneof='data', + message='IssueMatchData', + ) + channel_tag: int = proto.Field( + proto.INT32, + number=1, + ) + annotation_start_boundary: 'AnnotationBoundary' = proto.Field( + proto.MESSAGE, + number=4, + message='AnnotationBoundary', + ) + annotation_end_boundary: 'AnnotationBoundary' = proto.Field( + proto.MESSAGE, + number=5, + message='AnnotationBoundary', + ) + + +class AnnotationBoundary(proto.Message): + r"""A point in a conversation that marks the start or the end of + an annotation. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + word_index (int): + The word index of this boundary with respect + to the first word in the transcript piece. This + index starts at zero. + + This field is a member of `oneof`_ ``detailed_boundary``. + transcript_index (int): + The index in the sequence of transcribed + pieces of the conversation where the boundary is + located. This index starts at zero. + """ + + word_index: int = proto.Field( + proto.INT32, + number=3, + oneof='detailed_boundary', + ) + transcript_index: int = proto.Field( + proto.INT32, + number=1, + ) + + +class Entity(proto.Message): + r"""The data for an entity annotation. + Represents a phrase in the conversation that is a known entity, + such as a person, an organization, or location. + + Attributes: + display_name (str): + The representative name for the entity. + type_ (google.cloud.contact_center_insights_v1.types.Entity.Type): + The entity type. + metadata (MutableMapping[str, str]): + Metadata associated with the entity. + + For most entity types, the metadata is a Wikipedia URL + (``wikipedia_url``) and Knowledge Graph MID (``mid``), if + they are available. For the metadata associated with other + entity types, see the Type table below. + salience (float): + The salience score associated with the entity in the [0, + 1.0] range. + + The salience score for an entity provides information about + the importance or centrality of that entity to the entire + document text. Scores closer to 0 are less salient, while + scores closer to 1.0 are highly salient. + sentiment (google.cloud.contact_center_insights_v1.types.SentimentData): + The aggregate sentiment expressed for this + entity in the conversation. + """ + class Type(proto.Enum): + r"""The type of the entity. For most entity types, the associated + metadata is a Wikipedia URL (``wikipedia_url``) and Knowledge Graph + MID (``mid``). The table below lists the associated fields for + entities that have different metadata. + + Values: + TYPE_UNSPECIFIED (0): + Unspecified. + PERSON (1): + Person. + LOCATION (2): + Location. + ORGANIZATION (3): + Organization. + EVENT (4): + Event. + WORK_OF_ART (5): + Artwork. + CONSUMER_GOOD (6): + Consumer product. + OTHER (7): + Other types of entities. + PHONE_NUMBER (9): + Phone number. + + The metadata lists the phone number (formatted according to + local convention), plus whichever additional elements appear + in the text: + + - ``number`` - The actual number, broken down into sections + according to local convention. + - ``national_prefix`` - Country code, if detected. + - ``area_code`` - Region or area code, if detected. + - ``extension`` - Phone extension (to be dialed after + connection), if detected. + ADDRESS (10): + Address. + + The metadata identifies the street number and locality plus + whichever additional elements appear in the text: + + - ``street_number`` - Street number. + - ``locality`` - City or town. + - ``street_name`` - Street/route name, if detected. + - ``postal_code`` - Postal code, if detected. + - ``country`` - Country, if detected. + - ``broad_region`` - Administrative area, such as the + state, if detected. + - ``narrow_region`` - Smaller administrative area, such as + county, if detected. + - ``sublocality`` - Used in Asian addresses to demark a + district within a city, if detected. + DATE (11): + Date. + + The metadata identifies the components of the date: + + - ``year`` - Four digit year, if detected. + - ``month`` - Two digit month number, if detected. + - ``day`` - Two digit day number, if detected. + NUMBER (12): + Number. + + The metadata is the number itself. + PRICE (13): + Price. + + The metadata identifies the ``value`` and ``currency``. + """ + TYPE_UNSPECIFIED = 0 + PERSON = 1 + LOCATION = 2 + ORGANIZATION = 3 + EVENT = 4 + WORK_OF_ART = 5 + CONSUMER_GOOD = 6 + OTHER = 7 + PHONE_NUMBER = 9 + ADDRESS = 10 + DATE = 11 + NUMBER = 12 + PRICE = 13 + + display_name: str = proto.Field( + proto.STRING, + number=1, + ) + type_: Type = proto.Field( + proto.ENUM, + number=2, + enum=Type, + ) + metadata: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=3, + ) + salience: float = proto.Field( + proto.FLOAT, + number=4, + ) + sentiment: 'SentimentData' = proto.Field( + proto.MESSAGE, + number=5, + message='SentimentData', + ) + + +class Intent(proto.Message): + r"""The data for an intent. Represents a detected intent in the + conversation, for example MAKES_PROMISE. + + Attributes: + id (str): + The unique identifier of the intent. + display_name (str): + The human-readable name of the intent. + """ + + id: str = proto.Field( + proto.STRING, + number=1, + ) + display_name: str = proto.Field( + proto.STRING, + number=2, + ) + + +class PhraseMatchData(proto.Message): + r"""The data for a matched phrase matcher. + Represents information identifying a phrase matcher for a given + match. + + Attributes: + phrase_matcher (str): + The unique identifier (the resource name) of + the phrase matcher. + display_name (str): + The human-readable name of the phrase + matcher. + """ + + phrase_matcher: str = proto.Field( + proto.STRING, + number=1, + ) + display_name: str = proto.Field( + proto.STRING, + number=2, + ) + + +class DialogflowIntent(proto.Message): + r"""The data for a Dialogflow intent. Represents a detected intent in + the conversation, e.g. MAKES_PROMISE. + + Attributes: + display_name (str): + The human-readable name of the intent. + """ + + display_name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class InterruptionData(proto.Message): + r"""The data for an interruption annotation. + """ + + +class SilenceData(proto.Message): + r"""The data for a silence annotation. + """ + + +class HoldData(proto.Message): + r"""The data for a hold annotation. + """ + + +class EntityMentionData(proto.Message): + r"""The data for an entity mention annotation. This represents a mention + of an ``Entity`` in the conversation. + + Attributes: + entity_unique_id (str): + The key of this entity in conversation entities. Can be used + to retrieve the exact ``Entity`` this mention is attached + to. + type_ (google.cloud.contact_center_insights_v1.types.EntityMentionData.MentionType): + The type of the entity mention. + sentiment (google.cloud.contact_center_insights_v1.types.SentimentData): + Sentiment expressed for this mention of the + entity. + """ + class MentionType(proto.Enum): + r"""The supported types of mentions. + + Values: + MENTION_TYPE_UNSPECIFIED (0): + Unspecified. + PROPER (1): + Proper noun. + COMMON (2): + Common noun (or noun compound). + """ + MENTION_TYPE_UNSPECIFIED = 0 + PROPER = 1 + COMMON = 2 + + entity_unique_id: str = proto.Field( + proto.STRING, + number=1, + ) + type_: MentionType = proto.Field( + proto.ENUM, + number=2, + enum=MentionType, + ) + sentiment: 'SentimentData' = proto.Field( + proto.MESSAGE, + number=3, + message='SentimentData', + ) + + +class IntentMatchData(proto.Message): + r"""The data for an intent match. + Represents an intent match for a text segment in the + conversation. A text segment can be part of a sentence, a + complete sentence, or an utterance with multiple sentences. + + Attributes: + intent_unique_id (str): + The id of the matched intent. + Can be used to retrieve the corresponding intent + information. + """ + + intent_unique_id: str = proto.Field( + proto.STRING, + number=1, + ) + + +class SentimentData(proto.Message): + r"""The data for a sentiment annotation. + + Attributes: + magnitude (float): + A non-negative number from 0 to infinity + which represents the abolute magnitude of + sentiment regardless of score. + score (float): + The sentiment score between -1.0 (negative) + and 1.0 (positive). + """ + + magnitude: float = proto.Field( + proto.FLOAT, + number=1, + ) + score: float = proto.Field( + proto.FLOAT, + number=2, + ) + + +class IssueMatchData(proto.Message): + r"""The data for an issue match annotation. + + Attributes: + issue_assignment (google.cloud.contact_center_insights_v1.types.IssueAssignment): + Information about the issue's assignment. + """ + + issue_assignment: 'IssueAssignment' = proto.Field( + proto.MESSAGE, + number=1, + message='IssueAssignment', + ) + + +class IssueModel(proto.Message): + r"""The issue model resource. + + Attributes: + name (str): + Immutable. The resource name of the issue model. Format: + projects/{project}/locations/{location}/issueModels/{issue_model} + display_name (str): + The representative name for the issue model. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this issue + model was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The most recent time at which + the issue model was updated. + issue_count (int): + Output only. Number of issues in this issue + model. + state (google.cloud.contact_center_insights_v1.types.IssueModel.State): + Output only. State of the model. + input_data_config (google.cloud.contact_center_insights_v1.types.IssueModel.InputDataConfig): + Configs for the input data that used to + create the issue model. + training_stats (google.cloud.contact_center_insights_v1.types.IssueModelLabelStats): + Output only. Immutable. The issue model's + label statistics on its training data. + model_type (google.cloud.contact_center_insights_v1.types.IssueModel.ModelType): + Type of the model. + language_code (str): + Language of the model. + """ + class State(proto.Enum): + r"""State of the model. + + Values: + STATE_UNSPECIFIED (0): + Unspecified. + UNDEPLOYED (1): + Model is not deployed but is ready to deploy. + DEPLOYING (2): + Model is being deployed. + DEPLOYED (3): + Model is deployed and is ready to be used. A + model can only be used in analysis if it's in + this state. + UNDEPLOYING (4): + Model is being undeployed. + DELETING (5): + Model is being deleted. + """ + STATE_UNSPECIFIED = 0 + UNDEPLOYED = 1 + DEPLOYING = 2 + DEPLOYED = 3 + UNDEPLOYING = 4 + DELETING = 5 + + class ModelType(proto.Enum): + r"""Type of the model. + + Values: + MODEL_TYPE_UNSPECIFIED (0): + Unspecified model type. + TYPE_V1 (1): + Type V1. + TYPE_V2 (2): + Type V2. + """ + MODEL_TYPE_UNSPECIFIED = 0 + TYPE_V1 = 1 + TYPE_V2 = 2 + + class InputDataConfig(proto.Message): + r"""Configs for the input data used to create the issue model. + + Attributes: + medium (google.cloud.contact_center_insights_v1.types.Conversation.Medium): + Medium of conversations used in training data. This field is + being deprecated. To specify the medium to be used in + training a new issue model, set the ``medium`` field on + ``filter``. + training_conversations_count (int): + Output only. Number of conversations used in + training. Output only. + filter (str): + A filter to reduce the conversations used for + training the model to a specific subset. + """ + + medium: 'Conversation.Medium' = proto.Field( + proto.ENUM, + number=1, + enum='Conversation.Medium', + ) + training_conversations_count: int = proto.Field( + proto.INT64, + number=2, + ) + filter: str = proto.Field( + proto.STRING, + number=3, + ) + + name: str = proto.Field( + proto.STRING, + number=1, + ) + display_name: str = proto.Field( + proto.STRING, + number=2, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + issue_count: int = proto.Field( + proto.INT64, + number=8, + ) + state: State = proto.Field( + proto.ENUM, + number=5, + enum=State, + ) + input_data_config: InputDataConfig = proto.Field( + proto.MESSAGE, + number=6, + message=InputDataConfig, + ) + training_stats: 'IssueModelLabelStats' = proto.Field( + proto.MESSAGE, + number=7, + message='IssueModelLabelStats', + ) + model_type: ModelType = proto.Field( + proto.ENUM, + number=9, + enum=ModelType, + ) + language_code: str = proto.Field( + proto.STRING, + number=10, + ) + + +class Issue(proto.Message): + r"""The issue resource. + + Attributes: + name (str): + Immutable. The resource name of the issue. Format: + projects/{project}/locations/{location}/issueModels/{issue_model}/issues/{issue} + display_name (str): + The representative name for the issue. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this issue was + created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The most recent time that this + issue was updated. + sample_utterances (MutableSequence[str]): + Output only. Resource names of the sample + representative utterances that match to this + issue. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + display_name: str = proto.Field( + proto.STRING, + number=2, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + sample_utterances: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=6, + ) + + +class IssueModelLabelStats(proto.Message): + r"""Aggregated statistics about an issue model. + + Attributes: + analyzed_conversations_count (int): + Number of conversations the issue model has + analyzed at this point in time. + unclassified_conversations_count (int): + Number of analyzed conversations for which no + issue was applicable at this point in time. + issue_stats (MutableMapping[str, google.cloud.contact_center_insights_v1.types.IssueModelLabelStats.IssueStats]): + Statistics on each issue. Key is the issue's + resource name. + """ + + class IssueStats(proto.Message): + r"""Aggregated statistics about an issue. + + Attributes: + issue (str): + Issue resource. Format: + projects/{project}/locations/{location}/issueModels/{issue_model}/issues/{issue} + labeled_conversations_count (int): + Number of conversations attached to the issue + at this point in time. + display_name (str): + Display name of the issue. + """ + + issue: str = proto.Field( + proto.STRING, + number=1, + ) + labeled_conversations_count: int = proto.Field( + proto.INT64, + number=2, + ) + display_name: str = proto.Field( + proto.STRING, + number=3, + ) + + analyzed_conversations_count: int = proto.Field( + proto.INT64, + number=1, + ) + unclassified_conversations_count: int = proto.Field( + proto.INT64, + number=2, + ) + issue_stats: MutableMapping[str, IssueStats] = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=3, + message=IssueStats, + ) + + +class PhraseMatcher(proto.Message): + r"""The phrase matcher resource. + + Attributes: + name (str): + The resource name of the phrase matcher. Format: + projects/{project}/locations/{location}/phraseMatchers/{phrase_matcher} + revision_id (str): + Output only. Immutable. The revision ID of + the phrase matcher. A new revision is committed + whenever the matcher is changed, except when it + is activated or deactivated. A server generated + random ID will be used. Example: + locations/global/phraseMatchers/my-first-matcher@1234567 + version_tag (str): + The customized version tag to use for the phrase matcher. If + not specified, it will default to ``revision_id``. + revision_create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The timestamp of when the + revision was created. It is also the create time + when a new matcher is added. + display_name (str): + The human-readable name of the phrase + matcher. + type_ (google.cloud.contact_center_insights_v1.types.PhraseMatcher.PhraseMatcherType): + Required. The type of this phrase matcher. + active (bool): + Applies the phrase matcher only when it is + active. + phrase_match_rule_groups (MutableSequence[google.cloud.contact_center_insights_v1.types.PhraseMatchRuleGroup]): + A list of phase match rule groups that are + included in this matcher. + activation_update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The most recent time at which + the activation status was updated. + role_match (google.cloud.contact_center_insights_v1.types.ConversationParticipant.Role): + The role whose utterances the phrase matcher should be + matched against. If the role is ROLE_UNSPECIFIED it will be + matched against any utterances in the transcript. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The most recent time at which + the phrase matcher was updated. + """ + class PhraseMatcherType(proto.Enum): + r"""Specifies how to combine each phrase match rule group to + determine whether there is a match. + + Values: + PHRASE_MATCHER_TYPE_UNSPECIFIED (0): + Unspecified. + ALL_OF (1): + Must meet all phrase match rule groups or + there is no match. + ANY_OF (2): + If any of the phrase match rule groups are + met, there is a match. + """ + PHRASE_MATCHER_TYPE_UNSPECIFIED = 0 + ALL_OF = 1 + ANY_OF = 2 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + revision_id: str = proto.Field( + proto.STRING, + number=2, + ) + version_tag: str = proto.Field( + proto.STRING, + number=3, + ) + revision_create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + display_name: str = proto.Field( + proto.STRING, + number=5, + ) + type_: PhraseMatcherType = proto.Field( + proto.ENUM, + number=6, + enum=PhraseMatcherType, + ) + active: bool = proto.Field( + proto.BOOL, + number=7, + ) + phrase_match_rule_groups: MutableSequence['PhraseMatchRuleGroup'] = proto.RepeatedField( + proto.MESSAGE, + number=8, + message='PhraseMatchRuleGroup', + ) + activation_update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=9, + message=timestamp_pb2.Timestamp, + ) + role_match: 'ConversationParticipant.Role' = proto.Field( + proto.ENUM, + number=10, + enum='ConversationParticipant.Role', + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=11, + message=timestamp_pb2.Timestamp, + ) + + +class PhraseMatchRuleGroup(proto.Message): + r"""A message representing a rule in the phrase matcher. + + Attributes: + type_ (google.cloud.contact_center_insights_v1.types.PhraseMatchRuleGroup.PhraseMatchRuleGroupType): + Required. The type of this phrase match rule + group. + phrase_match_rules (MutableSequence[google.cloud.contact_center_insights_v1.types.PhraseMatchRule]): + A list of phrase match rules that are + included in this group. + """ + class PhraseMatchRuleGroupType(proto.Enum): + r"""Specifies how to combine each phrase match rule for whether + there is a match. + + Values: + PHRASE_MATCH_RULE_GROUP_TYPE_UNSPECIFIED (0): + Unspecified. + ALL_OF (1): + Must meet all phrase match rules or there is + no match. + ANY_OF (2): + If any of the phrase match rules are met, + there is a match. + """ + PHRASE_MATCH_RULE_GROUP_TYPE_UNSPECIFIED = 0 + ALL_OF = 1 + ANY_OF = 2 + + type_: PhraseMatchRuleGroupType = proto.Field( + proto.ENUM, + number=1, + enum=PhraseMatchRuleGroupType, + ) + phrase_match_rules: MutableSequence['PhraseMatchRule'] = proto.RepeatedField( + proto.MESSAGE, + number=2, + message='PhraseMatchRule', + ) + + +class PhraseMatchRule(proto.Message): + r"""The data for a phrase match rule. + + Attributes: + query (str): + Required. The phrase to be matched. + negated (bool): + Specifies whether the phrase must be missing + from the transcript segment or present in the + transcript segment. + config (google.cloud.contact_center_insights_v1.types.PhraseMatchRuleConfig): + Provides additional information about the + rule that specifies how to apply the rule. + """ + + query: str = proto.Field( + proto.STRING, + number=1, + ) + negated: bool = proto.Field( + proto.BOOL, + number=2, + ) + config: 'PhraseMatchRuleConfig' = proto.Field( + proto.MESSAGE, + number=3, + message='PhraseMatchRuleConfig', + ) + + +class PhraseMatchRuleConfig(proto.Message): + r"""Configuration information of a phrase match rule. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + exact_match_config (google.cloud.contact_center_insights_v1.types.ExactMatchConfig): + The configuration for the exact match rule. + + This field is a member of `oneof`_ ``config``. + """ + + exact_match_config: 'ExactMatchConfig' = proto.Field( + proto.MESSAGE, + number=1, + oneof='config', + message='ExactMatchConfig', + ) + + +class ExactMatchConfig(proto.Message): + r"""Exact match configuration. + + Attributes: + case_sensitive (bool): + Whether to consider case sensitivity when + performing an exact match. + """ + + case_sensitive: bool = proto.Field( + proto.BOOL, + number=1, + ) + + +class Settings(proto.Message): + r"""The settings resource. + + Attributes: + name (str): + Immutable. The resource name of the settings + resource. Format: + + projects/{project}/locations/{location}/settings + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which the settings + was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which the settings + were last updated. + language_code (str): + A language code to be applied to each + transcript segment unless the segment already + specifies a language code. Language code + defaults to "en-US" if it is neither specified + on the segment nor here. + conversation_ttl (google.protobuf.duration_pb2.Duration): + The default TTL for newly-created + conversations. If a conversation has a specified + expiration, that value will be used instead. + Changing this value will not change the + expiration of existing conversations. + Conversations with no expire time persist until + they are deleted. + pubsub_notification_settings (MutableMapping[str, str]): + A map that maps a notification trigger to a Pub/Sub topic. + Each time a specified trigger occurs, Insights will notify + the corresponding Pub/Sub topic. + + Keys are notification triggers. Supported keys are: + + - "all-triggers": Notify each time any of the supported + triggers occurs. + - "create-analysis": Notify each time an analysis is + created. + - "create-conversation": Notify each time a conversation is + created. + - "export-insights-data": Notify each time an export is + complete. + - "update-conversation": Notify each time a conversation is + updated via UpdateConversation. + + Values are Pub/Sub topics. The format of each Pub/Sub topic + is: projects/{project}/topics/{topic} + analysis_config (google.cloud.contact_center_insights_v1.types.Settings.AnalysisConfig): + Default analysis settings. + 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): + r"""Default configuration when creating Analyses in Insights. + + Attributes: + runtime_integration_analysis_percentage (float): + Percentage of conversations created using Dialogflow runtime + integration to analyze automatically, between [0, 100]. + upload_conversation_analysis_percentage (float): + Percentage of conversations created using the + UploadConversation endpoint to analyze automatically, + between [0, 100]. + annotator_selector (google.cloud.contact_center_insights_v1.types.AnnotatorSelector): + To select the annotators to run and the + phrase matchers to use (if any). If not + specified, all annotators will be run. + """ + + runtime_integration_analysis_percentage: float = proto.Field( + proto.DOUBLE, + number=1, + ) + upload_conversation_analysis_percentage: float = proto.Field( + proto.DOUBLE, + number=6, + ) + annotator_selector: 'AnnotatorSelector' = proto.Field( + proto.MESSAGE, + number=5, + message='AnnotatorSelector', + ) + + name: str = proto.Field( + proto.STRING, + number=1, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + language_code: str = proto.Field( + proto.STRING, + number=4, + ) + conversation_ttl: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=5, + message=duration_pb2.Duration, + ) + pubsub_notification_settings: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=6, + ) + analysis_config: AnalysisConfig = proto.Field( + proto.MESSAGE, + number=7, + message=AnalysisConfig, + ) + redaction_config: 'RedactionConfig' = proto.Field( + proto.MESSAGE, + number=10, + message='RedactionConfig', + ) + speech_config: 'SpeechConfig' = proto.Field( + proto.MESSAGE, + number=11, + message='SpeechConfig', + ) + + +class RedactionConfig(proto.Message): + r"""DLP resources used for redaction while ingesting + conversations. + + Attributes: + deidentify_template (str): + The fully-qualified DLP deidentify template resource name. + Format: + ``projects/{project}/deidentifyTemplates/{template}`` + inspect_template (str): + The fully-qualified DLP inspect template resource name. + Format: + ``projects/{project}/locations/{location}/inspectTemplates/{template}`` + """ + + deidentify_template: str = proto.Field( + proto.STRING, + number=1, + ) + inspect_template: str = proto.Field( + proto.STRING, + number=2, + ) + + +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. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + article_suggestion (google.cloud.contact_center_insights_v1.types.ArticleSuggestionData): + Agent Assist Article Suggestion data. + + This field is a member of `oneof`_ ``data``. + faq_answer (google.cloud.contact_center_insights_v1.types.FaqAnswerData): + Agent Assist FAQ answer data. + + This field is a member of `oneof`_ ``data``. + smart_reply (google.cloud.contact_center_insights_v1.types.SmartReplyData): + Agent Assist Smart Reply data. + + This field is a member of `oneof`_ ``data``. + smart_compose_suggestion (google.cloud.contact_center_insights_v1.types.SmartComposeSuggestionData): + Agent Assist Smart Compose suggestion data. + + This field is a member of `oneof`_ ``data``. + dialogflow_interaction (google.cloud.contact_center_insights_v1.types.DialogflowInteractionData): + Dialogflow interaction data. + + This field is a member of `oneof`_ ``data``. + conversation_summarization_suggestion (google.cloud.contact_center_insights_v1.types.ConversationSummarizationSuggestionData): + Conversation summarization suggestion data. + + This field is a member of `oneof`_ ``data``. + annotation_id (str): + The unique identifier of the annotation. Format: + projects/{project}/locations/{location}/conversationDatasets/{dataset}/conversationDataItems/{data_item}/conversationAnnotations/{annotation} + create_time (google.protobuf.timestamp_pb2.Timestamp): + The time at which this annotation was + created. + start_boundary (google.cloud.contact_center_insights_v1.types.AnnotationBoundary): + The boundary in the conversation where the + annotation starts, inclusive. + end_boundary (google.cloud.contact_center_insights_v1.types.AnnotationBoundary): + The boundary in the conversation where the + annotation ends, inclusive. + answer_feedback (google.cloud.contact_center_insights_v1.types.AnswerFeedback): + The feedback that the customer has about the answer in + ``data``. + """ + + article_suggestion: 'ArticleSuggestionData' = proto.Field( + proto.MESSAGE, + number=6, + oneof='data', + message='ArticleSuggestionData', + ) + faq_answer: 'FaqAnswerData' = proto.Field( + proto.MESSAGE, + number=7, + oneof='data', + message='FaqAnswerData', + ) + smart_reply: 'SmartReplyData' = proto.Field( + proto.MESSAGE, + number=8, + oneof='data', + message='SmartReplyData', + ) + smart_compose_suggestion: 'SmartComposeSuggestionData' = proto.Field( + proto.MESSAGE, + number=9, + oneof='data', + message='SmartComposeSuggestionData', + ) + dialogflow_interaction: 'DialogflowInteractionData' = proto.Field( + proto.MESSAGE, + number=10, + oneof='data', + message='DialogflowInteractionData', + ) + conversation_summarization_suggestion: 'ConversationSummarizationSuggestionData' = proto.Field( + proto.MESSAGE, + number=12, + oneof='data', + message='ConversationSummarizationSuggestionData', + ) + annotation_id: str = proto.Field( + proto.STRING, + number=1, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + start_boundary: 'AnnotationBoundary' = proto.Field( + proto.MESSAGE, + number=3, + message='AnnotationBoundary', + ) + end_boundary: 'AnnotationBoundary' = proto.Field( + proto.MESSAGE, + number=4, + message='AnnotationBoundary', + ) + answer_feedback: 'AnswerFeedback' = proto.Field( + proto.MESSAGE, + number=5, + message='AnswerFeedback', + ) + + +class AnswerFeedback(proto.Message): + r"""The feedback that the customer has about a certain answer in + the conversation. + + Attributes: + correctness_level (google.cloud.contact_center_insights_v1.types.AnswerFeedback.CorrectnessLevel): + The correctness level of an answer. + clicked (bool): + Indicates whether an answer or item was + clicked by the human agent. + displayed (bool): + Indicates whether an answer or item was + displayed to the human agent in the agent + desktop UI. + """ + class CorrectnessLevel(proto.Enum): + r"""The correctness level of an answer. + + Values: + CORRECTNESS_LEVEL_UNSPECIFIED (0): + Correctness level unspecified. + NOT_CORRECT (1): + Answer is totally wrong. + PARTIALLY_CORRECT (2): + Answer is partially correct. + FULLY_CORRECT (3): + Answer is fully correct. + """ + CORRECTNESS_LEVEL_UNSPECIFIED = 0 + NOT_CORRECT = 1 + PARTIALLY_CORRECT = 2 + FULLY_CORRECT = 3 + + correctness_level: CorrectnessLevel = proto.Field( + proto.ENUM, + number=1, + enum=CorrectnessLevel, + ) + clicked: bool = proto.Field( + proto.BOOL, + number=2, + ) + displayed: bool = proto.Field( + proto.BOOL, + number=3, + ) + + +class ArticleSuggestionData(proto.Message): + r"""Agent Assist Article Suggestion data. + + Attributes: + title (str): + Article title. + uri (str): + Article URI. + confidence_score (float): + The system's confidence score that this + article is a good match for this conversation, + ranging from 0.0 (completely uncertain) to 1.0 + (completely certain). + metadata (MutableMapping[str, str]): + Map that contains metadata about the Article + Suggestion and the document that it originates + from. + query_record (str): + The name of the answer record. Format: + projects/{project}/locations/{location}/answerRecords/{answer_record} + source (str): + The knowledge document that this answer was extracted from. + Format: + projects/{project}/knowledgeBases/{knowledge_base}/documents/{document} + """ + + title: str = proto.Field( + proto.STRING, + number=1, + ) + uri: str = proto.Field( + proto.STRING, + number=2, + ) + confidence_score: float = proto.Field( + proto.FLOAT, + number=3, + ) + metadata: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=4, + ) + query_record: str = proto.Field( + proto.STRING, + number=5, + ) + source: str = proto.Field( + proto.STRING, + number=6, + ) + + +class FaqAnswerData(proto.Message): + r"""Agent Assist frequently-asked-question answer data. + + Attributes: + answer (str): + The piece of text from the ``source`` knowledge base + document. + confidence_score (float): + The system's confidence score that this + answer is a good match for this conversation, + ranging from 0.0 (completely uncertain) to 1.0 + (completely certain). + question (str): + The corresponding FAQ question. + metadata (MutableMapping[str, str]): + Map that contains metadata about the FAQ + answer and the document that it originates from. + query_record (str): + The name of the answer record. Format: + projects/{project}/locations/{location}/answerRecords/{answer_record} + source (str): + The knowledge document that this answer was extracted from. + Format: + projects/{project}/knowledgeBases/{knowledge_base}/documents/{document}. + """ + + answer: str = proto.Field( + proto.STRING, + number=1, + ) + confidence_score: float = proto.Field( + proto.FLOAT, + number=2, + ) + question: str = proto.Field( + proto.STRING, + number=3, + ) + metadata: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=4, + ) + query_record: str = proto.Field( + proto.STRING, + number=5, + ) + source: str = proto.Field( + proto.STRING, + number=6, + ) + + +class SmartReplyData(proto.Message): + r"""Agent Assist Smart Reply data. + + Attributes: + reply (str): + The content of the reply. + confidence_score (float): + The system's confidence score that this reply + is a good match for this conversation, ranging + from 0.0 (completely uncertain) to 1.0 + (completely certain). + metadata (MutableMapping[str, str]): + Map that contains metadata about the Smart + Reply and the document from which it originates. + query_record (str): + The name of the answer record. Format: + projects/{project}/locations/{location}/answerRecords/{answer_record} + """ + + reply: str = proto.Field( + proto.STRING, + number=1, + ) + confidence_score: float = proto.Field( + proto.DOUBLE, + number=2, + ) + metadata: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=3, + ) + query_record: str = proto.Field( + proto.STRING, + number=4, + ) + + +class SmartComposeSuggestionData(proto.Message): + r"""Agent Assist Smart Compose suggestion data. + + Attributes: + suggestion (str): + The content of the suggestion. + confidence_score (float): + The system's confidence score that this + suggestion is a good match for this + conversation, ranging from 0.0 (completely + uncertain) to 1.0 (completely certain). + metadata (MutableMapping[str, str]): + Map that contains metadata about the Smart + Compose suggestion and the document from which + it originates. + query_record (str): + The name of the answer record. Format: + projects/{project}/locations/{location}/answerRecords/{answer_record} + """ + + suggestion: str = proto.Field( + proto.STRING, + number=1, + ) + confidence_score: float = proto.Field( + proto.DOUBLE, + number=2, + ) + metadata: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=3, + ) + query_record: str = proto.Field( + proto.STRING, + number=4, + ) + + +class DialogflowInteractionData(proto.Message): + r"""Dialogflow interaction data. + + Attributes: + dialogflow_intent_id (str): + The Dialogflow intent resource path. Format: + projects/{project}/agent/{agent}/intents/{intent} + confidence (float): + The confidence of the match ranging from 0.0 + (completely uncertain) to 1.0 (completely + certain). + """ + + dialogflow_intent_id: str = proto.Field( + proto.STRING, + number=1, + ) + confidence: float = proto.Field( + proto.FLOAT, + number=2, + ) + + +class ConversationSummarizationSuggestionData(proto.Message): + r"""Conversation summarization suggestion data. + + Attributes: + text (str): + The summarization content that is + concatenated into one string. + text_sections (MutableMapping[str, str]): + The summarization content that is divided + into sections. The key is the section's name and + the value is the section's content. There is no + specific format for the key or value. + confidence (float): + The confidence score of the summarization. + metadata (MutableMapping[str, str]): + A map that contains metadata about the + summarization and the document from which it + originates. + answer_record (str): + The name of the answer record. Format: + projects/{project}/locations/{location}/answerRecords/{answer_record} + conversation_model (str): + The name of the model that generates this summary. Format: + projects/{project}/locations/{location}/conversationModels/{conversation_model} + """ + + text: str = proto.Field( + proto.STRING, + number=1, + ) + text_sections: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=5, + ) + confidence: float = proto.Field( + proto.FLOAT, + number=2, + ) + metadata: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=3, + ) + answer_record: str = proto.Field( + proto.STRING, + number=4, + ) + conversation_model: str = proto.Field( + proto.STRING, + number=6, + ) + + +class ConversationParticipant(proto.Message): + r"""The call participant speaking for a given utterance. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + dialogflow_participant_name (str): + The name of the participant provided by + Dialogflow. Format: + projects/{project}/locations/{location}/conversations/{conversation}/participants/{participant} + + This field is a member of `oneof`_ ``participant``. + user_id (str): + A user-specified ID representing the + participant. + + This field is a member of `oneof`_ ``participant``. + dialogflow_participant (str): + Deprecated. Use ``dialogflow_participant_name`` instead. The + name of the Dialogflow participant. Format: + projects/{project}/locations/{location}/conversations/{conversation}/participants/{participant} + obfuscated_external_user_id (str): + Obfuscated user ID from Dialogflow. + role (google.cloud.contact_center_insights_v1.types.ConversationParticipant.Role): + The role of the participant. + """ + class Role(proto.Enum): + r"""The role of the participant. + + Values: + ROLE_UNSPECIFIED (0): + Participant's role is not set. + HUMAN_AGENT (1): + Participant is a human agent. + AUTOMATED_AGENT (2): + Participant is an automated agent. + END_USER (3): + Participant is an end user who conversed with + the contact center. + ANY_AGENT (4): + Participant is either a human or automated + agent. + """ + ROLE_UNSPECIFIED = 0 + HUMAN_AGENT = 1 + AUTOMATED_AGENT = 2 + END_USER = 3 + ANY_AGENT = 4 + + dialogflow_participant_name: str = proto.Field( + proto.STRING, + number=5, + oneof='participant', + ) + user_id: str = proto.Field( + proto.STRING, + number=6, + oneof='participant', + ) + dialogflow_participant: str = proto.Field( + proto.STRING, + number=1, + ) + obfuscated_external_user_id: str = proto.Field( + proto.STRING, + number=3, + ) + role: Role = proto.Field( + proto.ENUM, + number=2, + enum=Role, + ) + + +class View(proto.Message): + r"""The View resource. + + Attributes: + name (str): + Immutable. The resource name of the view. + Format: + + projects/{project}/locations/{location}/views/{view} + display_name (str): + The human-readable display name of the view. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which this view was + created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The most recent time at which + the view was updated. + value (str): + String with specific view properties, must be + non-empty. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + display_name: str = proto.Field( + proto.STRING, + number=2, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + value: str = proto.Field( + proto.STRING, + number=5, + ) + + +class AnnotatorSelector(proto.Message): + r"""Selector of all available annotators and phrase matchers to + run. + + Attributes: + run_interruption_annotator (bool): + Whether to run the interruption annotator. + run_silence_annotator (bool): + Whether to run the silence annotator. + run_phrase_matcher_annotator (bool): + Whether to run the active phrase matcher + annotator(s). + phrase_matchers (MutableSequence[str]): + The list of phrase matchers to run. If not provided, all + active phrase matchers will be used. If inactive phrase + matchers are provided, they will not be used. Phrase + matchers will be run only if run_phrase_matcher_annotator is + set to true. Format: + projects/{project}/locations/{location}/phraseMatchers/{phrase_matcher} + run_sentiment_annotator (bool): + Whether to run the sentiment annotator. + run_entity_annotator (bool): + Whether to run the entity annotator. + run_intent_annotator (bool): + Whether to run the intent annotator. + run_issue_model_annotator (bool): + Whether to run the issue model annotator. A + model should have already been deployed for this + to take effect. + issue_models (MutableSequence[str]): + The issue model to run. If not provided, the most recently + deployed topic model will be used. The provided issue model + will only be used for inference if the issue model is + deployed and if run_issue_model_annotator is set to true. If + more than one issue model is provided, only the first + provided issue model will be used for inference. + run_summarization_annotator (bool): + Whether to run the summarization annotator. + summarization_config (google.cloud.contact_center_insights_v1.types.AnnotatorSelector.SummarizationConfig): + Configuration for the summarization + annotator. + """ + + class SummarizationConfig(proto.Message): + r"""Configuration for summarization. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + conversation_profile (str): + Resource name of the Dialogflow conversation profile. + Format: + projects/{project}/locations/{location}/conversationProfiles/{conversation_profile} + + This field is a member of `oneof`_ ``model_source``. + summarization_model (google.cloud.contact_center_insights_v1.types.AnnotatorSelector.SummarizationConfig.SummarizationModel): + Default summarization model to be used. + + This field is a member of `oneof`_ ``model_source``. + """ + class SummarizationModel(proto.Enum): + r"""Summarization model to use, if ``conversation_profile`` is not used. + + Values: + SUMMARIZATION_MODEL_UNSPECIFIED (0): + Unspecified summarization model. + BASELINE_MODEL (1): + The Insights baseline model. + """ + SUMMARIZATION_MODEL_UNSPECIFIED = 0 + BASELINE_MODEL = 1 + + conversation_profile: str = proto.Field( + proto.STRING, + number=1, + oneof='model_source', + ) + summarization_model: 'AnnotatorSelector.SummarizationConfig.SummarizationModel' = proto.Field( + proto.ENUM, + number=2, + oneof='model_source', + enum='AnnotatorSelector.SummarizationConfig.SummarizationModel', + ) + + run_interruption_annotator: bool = proto.Field( + proto.BOOL, + number=1, + ) + run_silence_annotator: bool = proto.Field( + proto.BOOL, + number=2, + ) + run_phrase_matcher_annotator: bool = proto.Field( + proto.BOOL, + number=3, + ) + phrase_matchers: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=4, + ) + run_sentiment_annotator: bool = proto.Field( + proto.BOOL, + number=5, + ) + run_entity_annotator: bool = proto.Field( + proto.BOOL, + number=6, + ) + run_intent_annotator: bool = proto.Field( + proto.BOOL, + number=7, + ) + run_issue_model_annotator: bool = proto.Field( + proto.BOOL, + number=8, + ) + issue_models: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=10, + ) + run_summarization_annotator: bool = proto.Field( + proto.BOOL, + number=9, + ) + summarization_config: SummarizationConfig = proto.Field( + proto.MESSAGE, + number=11, + message=SummarizationConfig, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/mypy.ini b/owl-bot-staging/google-cloud-contact-center-insights/v1/mypy.ini new file mode 100644 index 000000000000..574c5aed394b --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/mypy.ini @@ -0,0 +1,3 @@ +[mypy] +python_version = 3.7 +namespace_packages = True diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/noxfile.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/noxfile.py new file mode 100644 index 000000000000..0a250777705f --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/noxfile.py @@ -0,0 +1,184 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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 os +import pathlib +import shutil +import subprocess +import sys + + +import nox # type: ignore + +ALL_PYTHON = [ + "3.7", + "3.8", + "3.9", + "3.10", + "3.11", +] + +CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() + +LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" +PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") + +BLACK_VERSION = "black==22.3.0" +BLACK_PATHS = ["docs", "google", "tests", "samples", "noxfile.py", "setup.py"] +DEFAULT_PYTHON_VERSION = "3.11" + +nox.sessions = [ + "unit", + "cover", + "mypy", + "check_lower_bounds" + # exclude update_lower_bounds from default + "docs", + "blacken", + "lint", + "lint_setup_py", +] + +@nox.session(python=ALL_PYTHON) +def unit(session): + """Run the unit test suite.""" + + session.install('coverage', 'pytest', 'pytest-cov', 'pytest-asyncio', 'asyncmock; python_version < "3.8"') + session.install('-e', '.') + + session.run( + 'py.test', + '--quiet', + '--cov=google/cloud/contact_center_insights_v1/', + '--cov=tests/', + '--cov-config=.coveragerc', + '--cov-report=term', + '--cov-report=html', + os.path.join('tests', 'unit', ''.join(session.posargs)) + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def cover(session): + """Run the final coverage report. + This outputs the coverage report aggregating coverage from the unit + test runs (not system test runs), and then erases coverage data. + """ + session.install("coverage", "pytest-cov") + session.run("coverage", "report", "--show-missing", "--fail-under=100") + + session.run("coverage", "erase") + + +@nox.session(python=ALL_PYTHON) +def mypy(session): + """Run the type checker.""" + session.install( + 'mypy', + 'types-requests', + 'types-protobuf' + ) + session.install('.') + session.run( + 'mypy', + '--explicit-package-bases', + 'google', + ) + + +@nox.session +def update_lower_bounds(session): + """Update lower bounds in constraints.txt to match setup.py""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'update', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + + +@nox.session +def check_lower_bounds(session): + """Check lower bounds in setup.py are reflected in constraints file""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'check', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def docs(session): + """Build the docs for this library.""" + + session.install("-e", ".") + session.install("sphinx==7.0.1", "alabaster", "recommonmark") + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-W", # warnings as errors + "-T", # show full traceback on exception + "-N", # no colors + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def lint(session): + """Run linters. + + Returns a failure if the linters find linting errors or sufficiently + serious code quality issues. + """ + session.install("flake8", BLACK_VERSION) + session.run( + "black", + "--check", + *BLACK_PATHS, + ) + session.run("flake8", "google", "tests", "samples") + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def blacken(session): + """Run black. Format code to uniform standard.""" + session.install(BLACK_VERSION) + session.run( + "black", + *BLACK_PATHS, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def lint_setup_py(session): + """Verify that setup.py is valid (including RST check).""" + session.install("docutils", "pygments") + session.run("python", "setup.py", "check", "--restructuredtext", "--strict") diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_async.py new file mode 100644 index 000000000000..68cbb8faca8f --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_async.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BulkAnalyzeConversations +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_BulkAnalyzeConversations_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_bulk_analyze_conversations(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.BulkAnalyzeConversationsRequest( + parent="parent_value", + filter="filter_value", + analysis_percentage=0.20170000000000002, + ) + + # Make the request + operation = client.bulk_analyze_conversations(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_BulkAnalyzeConversations_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_sync.py new file mode 100644 index 000000000000..ceac1fb7f825 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_sync.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BulkAnalyzeConversations +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_BulkAnalyzeConversations_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_bulk_analyze_conversations(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.BulkAnalyzeConversationsRequest( + parent="parent_value", + filter="filter_value", + analysis_percentage=0.20170000000000002, + ) + + # Make the request + operation = client.bulk_analyze_conversations(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_BulkAnalyzeConversations_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_async.py new file mode 100644 index 000000000000..4b029eb09247 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CalculateIssueModelStats +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CalculateIssueModelStats_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_calculate_issue_model_stats(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CalculateIssueModelStatsRequest( + issue_model="issue_model_value", + ) + + # Make the request + response = await client.calculate_issue_model_stats(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CalculateIssueModelStats_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_sync.py new file mode 100644 index 000000000000..a801c0974a17 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CalculateIssueModelStats +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CalculateIssueModelStats_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_calculate_issue_model_stats(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CalculateIssueModelStatsRequest( + issue_model="issue_model_value", + ) + + # Make the request + response = client.calculate_issue_model_stats(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CalculateIssueModelStats_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_async.py new file mode 100644 index 000000000000..eba9f4023e94 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CalculateStats +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CalculateStats_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_calculate_stats(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CalculateStatsRequest( + location="location_value", + ) + + # Make the request + response = await client.calculate_stats(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CalculateStats_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_sync.py new file mode 100644 index 000000000000..852d0c9a8b6c --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CalculateStats +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CalculateStats_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_calculate_stats(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CalculateStatsRequest( + location="location_value", + ) + + # Make the request + response = client.calculate_stats(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CalculateStats_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_async.py new file mode 100644 index 000000000000..bcd0bce51d52 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateAnalysis +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysis_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_create_analysis(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateAnalysisRequest( + parent="parent_value", + ) + + # Make the request + operation = client.create_analysis(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysis_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_sync.py new file mode 100644 index 000000000000..7783a422e609 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateAnalysis +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysis_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_create_analysis(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateAnalysisRequest( + parent="parent_value", + ) + + # Make the request + operation = client.create_analysis(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysis_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_conversation_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_conversation_async.py new file mode 100644 index 000000000000..c12d420c9c35 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_conversation_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateConversation +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateConversation_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_create_conversation(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateConversationRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_conversation(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateConversation_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_conversation_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_conversation_sync.py new file mode 100644 index 000000000000..3bdfd048c222 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_conversation_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateConversation +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateConversation_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_create_conversation(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateConversationRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_conversation(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateConversation_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_async.py new file mode 100644 index 000000000000..d83009c8eedf --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateIssueModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateIssueModel_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_create_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateIssueModelRequest( + parent="parent_value", + ) + + # Make the request + operation = client.create_issue_model(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateIssueModel_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_sync.py new file mode 100644 index 000000000000..4ce5d853cad2 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateIssueModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateIssueModel_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_create_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateIssueModelRequest( + parent="parent_value", + ) + + # Make the request + operation = client.create_issue_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateIssueModel_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_async.py new file mode 100644 index 000000000000..0f5f4f29898d --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreatePhraseMatcher +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreatePhraseMatcher_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_create_phrase_matcher(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + phrase_matcher = contact_center_insights_v1.PhraseMatcher() + phrase_matcher.type_ = "ANY_OF" + + request = contact_center_insights_v1.CreatePhraseMatcherRequest( + parent="parent_value", + phrase_matcher=phrase_matcher, + ) + + # Make the request + response = await client.create_phrase_matcher(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreatePhraseMatcher_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_sync.py new file mode 100644 index 000000000000..6d7c68bd7449 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreatePhraseMatcher +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreatePhraseMatcher_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_create_phrase_matcher(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + phrase_matcher = contact_center_insights_v1.PhraseMatcher() + phrase_matcher.type_ = "ANY_OF" + + request = contact_center_insights_v1.CreatePhraseMatcherRequest( + parent="parent_value", + phrase_matcher=phrase_matcher, + ) + + # Make the request + response = client.create_phrase_matcher(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreatePhraseMatcher_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_view_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_view_async.py new file mode 100644 index 000000000000..9873dbea6e4a --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_view_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateView +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateView_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_create_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateViewRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_view(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateView_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_view_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_view_sync.py new file mode 100644 index 000000000000..6141541f6493 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_view_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateView +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateView_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_create_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.CreateViewRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_view(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateView_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_async.py new file mode 100644 index 000000000000..79314602b54a --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteAnalysis +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysis_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_delete_analysis(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteAnalysisRequest( + name="name_value", + ) + + # Make the request + await client.delete_analysis(request=request) + + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysis_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_sync.py new file mode 100644 index 000000000000..d4a876727da9 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteAnalysis +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysis_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_delete_analysis(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteAnalysisRequest( + name="name_value", + ) + + # Make the request + client.delete_analysis(request=request) + + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysis_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_async.py new file mode 100644 index 000000000000..6640928d9e03 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteConversation +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteConversation_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_delete_conversation(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteConversationRequest( + name="name_value", + ) + + # Make the request + await client.delete_conversation(request=request) + + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteConversation_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_sync.py new file mode 100644 index 000000000000..8222cf303ec4 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteConversation +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteConversation_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_delete_conversation(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteConversationRequest( + name="name_value", + ) + + # Make the request + client.delete_conversation(request=request) + + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteConversation_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_async.py new file mode 100644 index 000000000000..2fa8538c91ec --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteIssue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssue_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_delete_issue(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteIssueRequest( + name="name_value", + ) + + # Make the request + await client.delete_issue(request=request) + + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssue_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_async.py new file mode 100644 index 000000000000..73bfc785d295 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteIssueModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssueModel_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_delete_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteIssueModelRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_issue_model(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssueModel_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_sync.py new file mode 100644 index 000000000000..43b681e40edb --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteIssueModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssueModel_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_delete_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteIssueModelRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_issue_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssueModel_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_sync.py new file mode 100644 index 000000000000..1a9559812956 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteIssue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssue_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_delete_issue(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteIssueRequest( + name="name_value", + ) + + # Make the request + client.delete_issue(request=request) + + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssue_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_async.py new file mode 100644 index 000000000000..4424e648a601 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeletePhraseMatcher +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeletePhraseMatcher_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_delete_phrase_matcher(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeletePhraseMatcherRequest( + name="name_value", + ) + + # Make the request + await client.delete_phrase_matcher(request=request) + + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeletePhraseMatcher_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_sync.py new file mode 100644 index 000000000000..c0ac075cca70 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeletePhraseMatcher +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeletePhraseMatcher_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_delete_phrase_matcher(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeletePhraseMatcherRequest( + name="name_value", + ) + + # Make the request + client.delete_phrase_matcher(request=request) + + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeletePhraseMatcher_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_view_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_view_async.py new file mode 100644 index 000000000000..1d1af8720171 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_view_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteView +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteView_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_delete_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteViewRequest( + name="name_value", + ) + + # Make the request + await client.delete_view(request=request) + + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteView_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_view_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_view_sync.py new file mode 100644 index 000000000000..57aa09a8a4b4 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_view_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteView +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteView_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_delete_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeleteViewRequest( + name="name_value", + ) + + # Make the request + client.delete_view(request=request) + + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteView_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_async.py new file mode 100644 index 000000000000..de05e6505002 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeployIssueModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeployIssueModel_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_deploy_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeployIssueModelRequest( + name="name_value", + ) + + # Make the request + operation = client.deploy_issue_model(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeployIssueModel_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_sync.py new file mode 100644 index 000000000000..32bbac86872d --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeployIssueModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeployIssueModel_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_deploy_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.DeployIssueModelRequest( + name="name_value", + ) + + # Make the request + operation = client.deploy_issue_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeployIssueModel_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_async.py new file mode 100644 index 000000000000..926818d9619b --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_async.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportInsightsData +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ExportInsightsData_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_export_insights_data(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + big_query_destination = contact_center_insights_v1.BigQueryDestination() + big_query_destination.dataset = "dataset_value" + + request = contact_center_insights_v1.ExportInsightsDataRequest( + big_query_destination=big_query_destination, + parent="parent_value", + ) + + # Make the request + operation = client.export_insights_data(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ExportInsightsData_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_sync.py new file mode 100644 index 000000000000..47d80c10c02b --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_sync.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportInsightsData +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ExportInsightsData_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_export_insights_data(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + big_query_destination = contact_center_insights_v1.BigQueryDestination() + big_query_destination.dataset = "dataset_value" + + request = contact_center_insights_v1.ExportInsightsDataRequest( + big_query_destination=big_query_destination, + parent="parent_value", + ) + + # Make the request + operation = client.export_insights_data(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ExportInsightsData_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_async.py new file mode 100644 index 000000000000..19b879c57016 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetAnalysis +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysis_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_get_analysis(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetAnalysisRequest( + name="name_value", + ) + + # Make the request + response = await client.get_analysis(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysis_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_sync.py new file mode 100644 index 000000000000..da794ff3405a --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetAnalysis +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysis_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_get_analysis(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetAnalysisRequest( + name="name_value", + ) + + # Make the request + response = client.get_analysis(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysis_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_conversation_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_conversation_async.py new file mode 100644 index 000000000000..d0023912ab58 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_conversation_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetConversation +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetConversation_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_get_conversation(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetConversationRequest( + name="name_value", + ) + + # Make the request + response = await client.get_conversation(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetConversation_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_conversation_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_conversation_sync.py new file mode 100644 index 000000000000..0cf65814d075 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_conversation_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetConversation +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetConversation_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_get_conversation(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetConversationRequest( + name="name_value", + ) + + # Make the request + response = client.get_conversation(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetConversation_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_async.py new file mode 100644 index 000000000000..51423a5a0bf6 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIssue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetIssue_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_get_issue(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetIssueRequest( + name="name_value", + ) + + # Make the request + response = await client.get_issue(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetIssue_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_async.py new file mode 100644 index 000000000000..f58e9d3eb689 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIssueModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetIssueModel_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_get_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetIssueModelRequest( + name="name_value", + ) + + # Make the request + response = await client.get_issue_model(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetIssueModel_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_sync.py new file mode 100644 index 000000000000..8f602f7319b7 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIssueModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetIssueModel_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_get_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetIssueModelRequest( + name="name_value", + ) + + # Make the request + response = client.get_issue_model(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetIssueModel_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_sync.py new file mode 100644 index 000000000000..572ce1cd362c --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIssue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetIssue_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_get_issue(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetIssueRequest( + name="name_value", + ) + + # Make the request + response = client.get_issue(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetIssue_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_async.py new file mode 100644 index 000000000000..78bf70f71166 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetPhraseMatcher +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetPhraseMatcher_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_get_phrase_matcher(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetPhraseMatcherRequest( + name="name_value", + ) + + # Make the request + response = await client.get_phrase_matcher(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetPhraseMatcher_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_sync.py new file mode 100644 index 000000000000..9473f7d6c2c5 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetPhraseMatcher +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetPhraseMatcher_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_get_phrase_matcher(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetPhraseMatcherRequest( + name="name_value", + ) + + # Make the request + response = client.get_phrase_matcher(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetPhraseMatcher_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_settings_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_settings_async.py new file mode 100644 index 000000000000..ab0789ab5a23 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_settings_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetSettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetSettings_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_get_settings(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetSettingsRequest( + name="name_value", + ) + + # Make the request + response = await client.get_settings(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetSettings_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_settings_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_settings_sync.py new file mode 100644 index 000000000000..81d28e3ae3cf --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_settings_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetSettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetSettings_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_get_settings(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetSettingsRequest( + name="name_value", + ) + + # Make the request + response = client.get_settings(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetSettings_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_view_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_view_async.py new file mode 100644 index 000000000000..db108050140f --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_view_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetView +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetView_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_get_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetViewRequest( + name="name_value", + ) + + # Make the request + response = await client.get_view(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetView_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_view_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_view_sync.py new file mode 100644 index 000000000000..320bd8d2ae32 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_view_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetView +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetView_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_get_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.GetViewRequest( + name="name_value", + ) + + # Make the request + response = client.get_view(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetView_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_async.py new file mode 100644 index 000000000000..45293b7187e2 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_async.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for IngestConversations +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_IngestConversations_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_ingest_conversations(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + gcs_source = contact_center_insights_v1.GcsSource() + gcs_source.bucket_uri = "bucket_uri_value" + + transcript_object_config = contact_center_insights_v1.TranscriptObjectConfig() + transcript_object_config.medium = "CHAT" + + request = contact_center_insights_v1.IngestConversationsRequest( + gcs_source=gcs_source, + transcript_object_config=transcript_object_config, + parent="parent_value", + ) + + # Make the request + operation = client.ingest_conversations(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_IngestConversations_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_sync.py new file mode 100644 index 000000000000..978fe8194701 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_sync.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for IngestConversations +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_IngestConversations_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_ingest_conversations(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + gcs_source = contact_center_insights_v1.GcsSource() + gcs_source.bucket_uri = "bucket_uri_value" + + transcript_object_config = contact_center_insights_v1.TranscriptObjectConfig() + transcript_object_config.medium = "CHAT" + + request = contact_center_insights_v1.IngestConversationsRequest( + gcs_source=gcs_source, + transcript_object_config=transcript_object_config, + parent="parent_value", + ) + + # Make the request + operation = client.ingest_conversations(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_IngestConversations_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analyses_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analyses_async.py new file mode 100644 index 000000000000..510ceb61d226 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analyses_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListAnalyses +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalyses_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_list_analyses(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListAnalysesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_analyses(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalyses_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analyses_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analyses_sync.py new file mode 100644 index 000000000000..73babf81c2ba --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analyses_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListAnalyses +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalyses_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_list_analyses(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListAnalysesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_analyses(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalyses_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_conversations_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_conversations_async.py new file mode 100644 index 000000000000..4afcfa9edee6 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_conversations_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListConversations +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListConversations_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_list_conversations(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListConversationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_conversations(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListConversations_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_conversations_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_conversations_sync.py new file mode 100644 index 000000000000..438e79d3c654 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_conversations_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListConversations +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListConversations_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_list_conversations(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListConversationsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_conversations(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListConversations_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_async.py new file mode 100644 index 000000000000..4c17eb81986f --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListIssueModels +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListIssueModels_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_list_issue_models(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListIssueModelsRequest( + parent="parent_value", + ) + + # Make the request + response = await client.list_issue_models(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListIssueModels_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_sync.py new file mode 100644 index 000000000000..da6334511189 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListIssueModels +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListIssueModels_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_list_issue_models(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListIssueModelsRequest( + parent="parent_value", + ) + + # Make the request + response = client.list_issue_models(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListIssueModels_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issues_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issues_async.py new file mode 100644 index 000000000000..f884ef647b62 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issues_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListIssues +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListIssues_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_list_issues(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListIssuesRequest( + parent="parent_value", + ) + + # Make the request + response = await client.list_issues(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListIssues_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issues_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issues_sync.py new file mode 100644 index 000000000000..879da47d32ae --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issues_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListIssues +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListIssues_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_list_issues(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListIssuesRequest( + parent="parent_value", + ) + + # Make the request + response = client.list_issues(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListIssues_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_async.py new file mode 100644 index 000000000000..5115bfcae255 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListPhraseMatchers +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListPhraseMatchers_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_list_phrase_matchers(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListPhraseMatchersRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_phrase_matchers(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListPhraseMatchers_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_sync.py new file mode 100644 index 000000000000..e0d0140d8804 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListPhraseMatchers +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListPhraseMatchers_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_list_phrase_matchers(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListPhraseMatchersRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_phrase_matchers(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListPhraseMatchers_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_views_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_views_async.py new file mode 100644 index 000000000000..b84905604b80 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_views_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListViews +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListViews_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_list_views(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListViewsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_views(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListViews_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_views_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_views_sync.py new file mode 100644 index 000000000000..421bdeeaa421 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_views_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListViews +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListViews_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_list_views(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.ListViewsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_views(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListViews_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_async.py new file mode 100644 index 000000000000..dcae28aaa7a7 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UndeployIssueModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UndeployIssueModel_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_undeploy_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UndeployIssueModelRequest( + name="name_value", + ) + + # Make the request + operation = client.undeploy_issue_model(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UndeployIssueModel_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_sync.py new file mode 100644 index 000000000000..2499e8463f97 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UndeployIssueModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UndeployIssueModel_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_undeploy_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UndeployIssueModelRequest( + name="name_value", + ) + + # Make the request + operation = client.undeploy_issue_model(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UndeployIssueModel_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_conversation_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_conversation_async.py new file mode 100644 index 000000000000..bad2357420be --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_conversation_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateConversation +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateConversation_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_update_conversation(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateConversationRequest( + ) + + # Make the request + response = await client.update_conversation(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateConversation_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_conversation_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_conversation_sync.py new file mode 100644 index 000000000000..a05422e0381a --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_conversation_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateConversation +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateConversation_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_update_conversation(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateConversationRequest( + ) + + # Make the request + response = client.update_conversation(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateConversation_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_async.py new file mode 100644 index 000000000000..aed4214ee18f --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateIssue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssue_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_update_issue(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateIssueRequest( + ) + + # Make the request + response = await client.update_issue(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssue_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_async.py new file mode 100644 index 000000000000..2589c1695f08 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateIssueModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssueModel_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_update_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateIssueModelRequest( + ) + + # Make the request + response = await client.update_issue_model(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssueModel_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_sync.py new file mode 100644 index 000000000000..eb83e74bc68d --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateIssueModel +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssueModel_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_update_issue_model(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateIssueModelRequest( + ) + + # Make the request + response = client.update_issue_model(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssueModel_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_sync.py new file mode 100644 index 000000000000..25946b42b8c2 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateIssue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssue_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_update_issue(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateIssueRequest( + ) + + # Make the request + response = client.update_issue(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssue_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_async.py new file mode 100644 index 000000000000..61a9c0c624b2 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_async.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdatePhraseMatcher +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdatePhraseMatcher_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_update_phrase_matcher(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + phrase_matcher = contact_center_insights_v1.PhraseMatcher() + phrase_matcher.type_ = "ANY_OF" + + request = contact_center_insights_v1.UpdatePhraseMatcherRequest( + phrase_matcher=phrase_matcher, + ) + + # Make the request + response = await client.update_phrase_matcher(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdatePhraseMatcher_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_sync.py new file mode 100644 index 000000000000..f3fcacb9cd8c --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_sync.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdatePhraseMatcher +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdatePhraseMatcher_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_update_phrase_matcher(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + phrase_matcher = contact_center_insights_v1.PhraseMatcher() + phrase_matcher.type_ = "ANY_OF" + + request = contact_center_insights_v1.UpdatePhraseMatcherRequest( + phrase_matcher=phrase_matcher, + ) + + # Make the request + response = client.update_phrase_matcher(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdatePhraseMatcher_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_settings_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_settings_async.py new file mode 100644 index 000000000000..1b5b362be1a2 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_settings_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateSettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateSettings_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_update_settings(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateSettingsRequest( + ) + + # Make the request + response = await client.update_settings(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateSettings_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_settings_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_settings_sync.py new file mode 100644 index 000000000000..55ff02c2a757 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_settings_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateSettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateSettings_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_update_settings(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateSettingsRequest( + ) + + # Make the request + response = client.update_settings(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateSettings_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_view_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_view_async.py new file mode 100644 index 000000000000..9191f182b1f7 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_view_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateView +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateView_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_update_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateViewRequest( + ) + + # Make the request + response = await client.update_view(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateView_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_view_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_view_sync.py new file mode 100644 index 000000000000..930c18e183a1 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_view_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateView +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateView_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_update_view(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UpdateViewRequest( + ) + + # Make the request + response = client.update_view(request=request) + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateView_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_async.py new file mode 100644 index 000000000000..379c9766dadc --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UploadConversation +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UploadConversation_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +async def sample_upload_conversation(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UploadConversationRequest( + parent="parent_value", + ) + + # Make the request + operation = client.upload_conversation(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UploadConversation_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_sync.py new file mode 100644 index 000000000000..6d7fcac3ed7a --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UploadConversation +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-contact-center-insights + + +# [START contactcenterinsights_v1_generated_ContactCenterInsights_UploadConversation_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import contact_center_insights_v1 + + +def sample_upload_conversation(): + # Create a client + client = contact_center_insights_v1.ContactCenterInsightsClient() + + # Initialize request argument(s) + request = contact_center_insights_v1.UploadConversationRequest( + parent="parent_value", + ) + + # Make the request + operation = client.upload_conversation(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END contactcenterinsights_v1_generated_ContactCenterInsights_UploadConversation_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/snippet_metadata_google.cloud.contactcenterinsights.v1.json b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/snippet_metadata_google.cloud.contactcenterinsights.v1.json new file mode 100644 index 000000000000..c3e9d3df64ac --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/snippet_metadata_google.cloud.contactcenterinsights.v1.json @@ -0,0 +1,6207 @@ +{ + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.contactcenterinsights.v1", + "version": "v1" + } + ], + "language": "PYTHON", + "name": "google-cloud-contact-center-insights", + "version": "0.1.0" + }, + "snippets": [ + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.bulk_analyze_conversations", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.BulkAnalyzeConversations", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "BulkAnalyzeConversations" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.BulkAnalyzeConversationsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "filter", + "type": "str" + }, + { + "name": "analysis_percentage", + "type": "float" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "bulk_analyze_conversations" + }, + "description": "Sample for BulkAnalyzeConversations", + "file": "contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_BulkAnalyzeConversations_async", + "segments": [ + { + "end": 57, + "start": 27, + "type": "FULL" + }, + { + "end": 57, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 54, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 58, + "start": 55, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.bulk_analyze_conversations", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.BulkAnalyzeConversations", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "BulkAnalyzeConversations" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.BulkAnalyzeConversationsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "filter", + "type": "str" + }, + { + "name": "analysis_percentage", + "type": "float" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "bulk_analyze_conversations" + }, + "description": "Sample for BulkAnalyzeConversations", + "file": "contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_BulkAnalyzeConversations_sync", + "segments": [ + { + "end": 57, + "start": 27, + "type": "FULL" + }, + { + "end": 57, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 54, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 58, + "start": 55, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.calculate_issue_model_stats", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CalculateIssueModelStats", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "CalculateIssueModelStats" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsRequest" + }, + { + "name": "issue_model", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsResponse", + "shortName": "calculate_issue_model_stats" + }, + "description": "Sample for CalculateIssueModelStats", + "file": "contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CalculateIssueModelStats_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.calculate_issue_model_stats", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CalculateIssueModelStats", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "CalculateIssueModelStats" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsRequest" + }, + { + "name": "issue_model", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsResponse", + "shortName": "calculate_issue_model_stats" + }, + "description": "Sample for CalculateIssueModelStats", + "file": "contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CalculateIssueModelStats_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.calculate_stats", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CalculateStats", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "CalculateStats" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.CalculateStatsRequest" + }, + { + "name": "location", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.CalculateStatsResponse", + "shortName": "calculate_stats" + }, + "description": "Sample for CalculateStats", + "file": "contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CalculateStats_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.calculate_stats", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CalculateStats", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "CalculateStats" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.CalculateStatsRequest" + }, + { + "name": "location", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.CalculateStatsResponse", + "shortName": "calculate_stats" + }, + "description": "Sample for CalculateStats", + "file": "contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CalculateStats_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_analysis", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateAnalysis", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "CreateAnalysis" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.CreateAnalysisRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "analysis", + "type": "google.cloud.contact_center_insights_v1.types.Analysis" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_analysis" + }, + "description": "Sample for CreateAnalysis", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_analysis_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysis_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_analysis_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_analysis", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateAnalysis", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "CreateAnalysis" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.CreateAnalysisRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "analysis", + "type": "google.cloud.contact_center_insights_v1.types.Analysis" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_analysis" + }, + "description": "Sample for CreateAnalysis", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_analysis_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysis_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_analysis_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_conversation", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateConversation", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "CreateConversation" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.CreateConversationRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "conversation", + "type": "google.cloud.contact_center_insights_v1.types.Conversation" + }, + { + "name": "conversation_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", + "shortName": "create_conversation" + }, + "description": "Sample for CreateConversation", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_conversation_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateConversation_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_conversation_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_conversation", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateConversation", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "CreateConversation" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.CreateConversationRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "conversation", + "type": "google.cloud.contact_center_insights_v1.types.Conversation" + }, + { + "name": "conversation_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", + "shortName": "create_conversation" + }, + "description": "Sample for CreateConversation", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_conversation_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateConversation_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_conversation_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_issue_model", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateIssueModel", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "CreateIssueModel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.CreateIssueModelRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "issue_model", + "type": "google.cloud.contact_center_insights_v1.types.IssueModel" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_issue_model" + }, + "description": "Sample for CreateIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateIssueModel_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_issue_model", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateIssueModel", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "CreateIssueModel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.CreateIssueModelRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "issue_model", + "type": "google.cloud.contact_center_insights_v1.types.IssueModel" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_issue_model" + }, + "description": "Sample for CreateIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateIssueModel_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_phrase_matcher", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreatePhraseMatcher", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "CreatePhraseMatcher" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.CreatePhraseMatcherRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "phrase_matcher", + "type": "google.cloud.contact_center_insights_v1.types.PhraseMatcher" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", + "shortName": "create_phrase_matcher" + }, + "description": "Sample for CreatePhraseMatcher", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreatePhraseMatcher_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_phrase_matcher", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreatePhraseMatcher", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "CreatePhraseMatcher" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.CreatePhraseMatcherRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "phrase_matcher", + "type": "google.cloud.contact_center_insights_v1.types.PhraseMatcher" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", + "shortName": "create_phrase_matcher" + }, + "description": "Sample for CreatePhraseMatcher", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreatePhraseMatcher_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_view", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateView", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "CreateView" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.CreateViewRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "view", + "type": "google.cloud.contact_center_insights_v1.types.View" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.View", + "shortName": "create_view" + }, + "description": "Sample for CreateView", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_view_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateView_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_view_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_view", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateView", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "CreateView" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.CreateViewRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "view", + "type": "google.cloud.contact_center_insights_v1.types.View" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.View", + "shortName": "create_view" + }, + "description": "Sample for CreateView", + "file": "contactcenterinsights_v1_generated_contact_center_insights_create_view_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateView_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_create_view_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_analysis", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteAnalysis", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "DeleteAnalysis" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.DeleteAnalysisRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_analysis" + }, + "description": "Sample for DeleteAnalysis", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysis_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_analysis", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteAnalysis", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "DeleteAnalysis" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.DeleteAnalysisRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_analysis" + }, + "description": "Sample for DeleteAnalysis", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysis_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_conversation", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteConversation", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "DeleteConversation" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.DeleteConversationRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_conversation" + }, + "description": "Sample for DeleteConversation", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteConversation_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_conversation", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteConversation", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "DeleteConversation" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.DeleteConversationRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_conversation" + }, + "description": "Sample for DeleteConversation", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteConversation_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_issue_model", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteIssueModel", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "DeleteIssueModel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.DeleteIssueModelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_issue_model" + }, + "description": "Sample for DeleteIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssueModel_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_issue_model", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteIssueModel", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "DeleteIssueModel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.DeleteIssueModelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_issue_model" + }, + "description": "Sample for DeleteIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssueModel_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_issue", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteIssue", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "DeleteIssue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.DeleteIssueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_issue" + }, + "description": "Sample for DeleteIssue", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssue_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_issue", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteIssue", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "DeleteIssue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.DeleteIssueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_issue" + }, + "description": "Sample for DeleteIssue", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssue_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_phrase_matcher", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeletePhraseMatcher", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "DeletePhraseMatcher" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.DeletePhraseMatcherRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_phrase_matcher" + }, + "description": "Sample for DeletePhraseMatcher", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeletePhraseMatcher_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_phrase_matcher", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeletePhraseMatcher", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "DeletePhraseMatcher" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.DeletePhraseMatcherRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_phrase_matcher" + }, + "description": "Sample for DeletePhraseMatcher", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeletePhraseMatcher_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_view", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteView", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "DeleteView" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.DeleteViewRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_view" + }, + "description": "Sample for DeleteView", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_view_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteView_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_view_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_view", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteView", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "DeleteView" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.DeleteViewRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_view" + }, + "description": "Sample for DeleteView", + "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_view_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteView_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_view_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.deploy_issue_model", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeployIssueModel", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "DeployIssueModel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.DeployIssueModelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "deploy_issue_model" + }, + "description": "Sample for DeployIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeployIssueModel_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.deploy_issue_model", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeployIssueModel", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "DeployIssueModel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.DeployIssueModelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "deploy_issue_model" + }, + "description": "Sample for DeployIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeployIssueModel_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.export_insights_data", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ExportInsightsData", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ExportInsightsData" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "export_insights_data" + }, + "description": "Sample for ExportInsightsData", + "file": "contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ExportInsightsData_async", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 56, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 57, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.export_insights_data", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ExportInsightsData", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ExportInsightsData" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "export_insights_data" + }, + "description": "Sample for ExportInsightsData", + "file": "contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ExportInsightsData_sync", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 56, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 57, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_analysis", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetAnalysis", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetAnalysis" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetAnalysisRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Analysis", + "shortName": "get_analysis" + }, + "description": "Sample for GetAnalysis", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_analysis_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysis_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_analysis_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_analysis", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetAnalysis", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetAnalysis" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetAnalysisRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Analysis", + "shortName": "get_analysis" + }, + "description": "Sample for GetAnalysis", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_analysis_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysis_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_analysis_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_conversation", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetConversation", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetConversation" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetConversationRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", + "shortName": "get_conversation" + }, + "description": "Sample for GetConversation", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_conversation_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetConversation_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_conversation_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_conversation", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetConversation", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetConversation" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetConversationRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", + "shortName": "get_conversation" + }, + "description": "Sample for GetConversation", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_conversation_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetConversation_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_conversation_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_issue_model", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetIssueModel", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetIssueModel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetIssueModelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.IssueModel", + "shortName": "get_issue_model" + }, + "description": "Sample for GetIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetIssueModel_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_issue_model", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetIssueModel", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetIssueModel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetIssueModelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.IssueModel", + "shortName": "get_issue_model" + }, + "description": "Sample for GetIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetIssueModel_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_issue", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetIssue", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetIssue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetIssueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Issue", + "shortName": "get_issue" + }, + "description": "Sample for GetIssue", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetIssue_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_issue", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetIssue", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetIssue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetIssueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Issue", + "shortName": "get_issue" + }, + "description": "Sample for GetIssue", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetIssue_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_phrase_matcher", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetPhraseMatcher", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetPhraseMatcher" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetPhraseMatcherRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", + "shortName": "get_phrase_matcher" + }, + "description": "Sample for GetPhraseMatcher", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetPhraseMatcher_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_phrase_matcher", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetPhraseMatcher", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetPhraseMatcher" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetPhraseMatcherRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", + "shortName": "get_phrase_matcher" + }, + "description": "Sample for GetPhraseMatcher", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetPhraseMatcher_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_settings", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetSettings", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetSettings" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetSettingsRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Settings", + "shortName": "get_settings" + }, + "description": "Sample for GetSettings", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_settings_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetSettings_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_settings_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_settings", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetSettings", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetSettings" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetSettingsRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Settings", + "shortName": "get_settings" + }, + "description": "Sample for GetSettings", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_settings_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetSettings_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_settings_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_view", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetView", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetView" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetViewRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.View", + "shortName": "get_view" + }, + "description": "Sample for GetView", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_view_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetView_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_view_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_view", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetView", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "GetView" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.GetViewRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.View", + "shortName": "get_view" + }, + "description": "Sample for GetView", + "file": "contactcenterinsights_v1_generated_contact_center_insights_get_view_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetView_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_get_view_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.ingest_conversations", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.IngestConversations", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "IngestConversations" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.IngestConversationsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "ingest_conversations" + }, + "description": "Sample for IngestConversations", + "file": "contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_IngestConversations_async", + "segments": [ + { + "end": 63, + "start": 27, + "type": "FULL" + }, + { + "end": 63, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 53, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 60, + "start": 54, + "type": "REQUEST_EXECUTION" + }, + { + "end": 64, + "start": 61, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.ingest_conversations", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.IngestConversations", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "IngestConversations" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.IngestConversationsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "ingest_conversations" + }, + "description": "Sample for IngestConversations", + "file": "contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_IngestConversations_sync", + "segments": [ + { + "end": 63, + "start": 27, + "type": "FULL" + }, + { + "end": 63, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 53, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 60, + "start": 54, + "type": "REQUEST_EXECUTION" + }, + { + "end": 64, + "start": 61, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_analyses", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListAnalyses", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListAnalyses" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListAnalysesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAnalysesAsyncPager", + "shortName": "list_analyses" + }, + "description": "Sample for ListAnalyses", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_analyses_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalyses_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_analyses_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_analyses", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListAnalyses", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListAnalyses" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListAnalysesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAnalysesPager", + "shortName": "list_analyses" + }, + "description": "Sample for ListAnalyses", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_analyses_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalyses_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_analyses_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_conversations", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListConversations", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListConversations" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListConversationsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListConversationsAsyncPager", + "shortName": "list_conversations" + }, + "description": "Sample for ListConversations", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_conversations_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListConversations_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_conversations_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_conversations", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListConversations", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListConversations" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListConversationsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListConversationsPager", + "shortName": "list_conversations" + }, + "description": "Sample for ListConversations", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_conversations_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListConversations_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_conversations_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_issue_models", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListIssueModels", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListIssueModels" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListIssueModelsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.ListIssueModelsResponse", + "shortName": "list_issue_models" + }, + "description": "Sample for ListIssueModels", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListIssueModels_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_issue_models", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListIssueModels", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListIssueModels" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListIssueModelsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.ListIssueModelsResponse", + "shortName": "list_issue_models" + }, + "description": "Sample for ListIssueModels", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListIssueModels_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_issues", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListIssues", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListIssues" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListIssuesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.ListIssuesResponse", + "shortName": "list_issues" + }, + "description": "Sample for ListIssues", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_issues_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListIssues_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_issues_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_issues", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListIssues", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListIssues" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListIssuesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.ListIssuesResponse", + "shortName": "list_issues" + }, + "description": "Sample for ListIssues", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_issues_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListIssues_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_issues_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_phrase_matchers", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListPhraseMatchers", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListPhraseMatchers" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListPhraseMatchersRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListPhraseMatchersAsyncPager", + "shortName": "list_phrase_matchers" + }, + "description": "Sample for ListPhraseMatchers", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListPhraseMatchers_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_phrase_matchers", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListPhraseMatchers", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListPhraseMatchers" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListPhraseMatchersRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListPhraseMatchersPager", + "shortName": "list_phrase_matchers" + }, + "description": "Sample for ListPhraseMatchers", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListPhraseMatchers_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_views", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListViews", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListViews" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListViewsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListViewsAsyncPager", + "shortName": "list_views" + }, + "description": "Sample for ListViews", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_views_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListViews_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_views_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_views", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListViews", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "ListViews" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.ListViewsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListViewsPager", + "shortName": "list_views" + }, + "description": "Sample for ListViews", + "file": "contactcenterinsights_v1_generated_contact_center_insights_list_views_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListViews_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_list_views_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.undeploy_issue_model", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UndeployIssueModel", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "UndeployIssueModel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.UndeployIssueModelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "undeploy_issue_model" + }, + "description": "Sample for UndeployIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UndeployIssueModel_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.undeploy_issue_model", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UndeployIssueModel", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "UndeployIssueModel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.UndeployIssueModelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "undeploy_issue_model" + }, + "description": "Sample for UndeployIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UndeployIssueModel_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_conversation", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateConversation", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "UpdateConversation" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.UpdateConversationRequest" + }, + { + "name": "conversation", + "type": "google.cloud.contact_center_insights_v1.types.Conversation" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", + "shortName": "update_conversation" + }, + "description": "Sample for UpdateConversation", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_conversation_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateConversation_async", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_conversation_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_conversation", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateConversation", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "UpdateConversation" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.UpdateConversationRequest" + }, + { + "name": "conversation", + "type": "google.cloud.contact_center_insights_v1.types.Conversation" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", + "shortName": "update_conversation" + }, + "description": "Sample for UpdateConversation", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_conversation_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateConversation_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_conversation_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_issue_model", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateIssueModel", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "UpdateIssueModel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.UpdateIssueModelRequest" + }, + { + "name": "issue_model", + "type": "google.cloud.contact_center_insights_v1.types.IssueModel" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.IssueModel", + "shortName": "update_issue_model" + }, + "description": "Sample for UpdateIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssueModel_async", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_issue_model", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateIssueModel", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "UpdateIssueModel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.UpdateIssueModelRequest" + }, + { + "name": "issue_model", + "type": "google.cloud.contact_center_insights_v1.types.IssueModel" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.IssueModel", + "shortName": "update_issue_model" + }, + "description": "Sample for UpdateIssueModel", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssueModel_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_issue", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateIssue", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "UpdateIssue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.UpdateIssueRequest" + }, + { + "name": "issue", + "type": "google.cloud.contact_center_insights_v1.types.Issue" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Issue", + "shortName": "update_issue" + }, + "description": "Sample for UpdateIssue", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssue_async", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_issue", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateIssue", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "UpdateIssue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.UpdateIssueRequest" + }, + { + "name": "issue", + "type": "google.cloud.contact_center_insights_v1.types.Issue" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Issue", + "shortName": "update_issue" + }, + "description": "Sample for UpdateIssue", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssue_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_phrase_matcher", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdatePhraseMatcher", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "UpdatePhraseMatcher" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.UpdatePhraseMatcherRequest" + }, + { + "name": "phrase_matcher", + "type": "google.cloud.contact_center_insights_v1.types.PhraseMatcher" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", + "shortName": "update_phrase_matcher" + }, + "description": "Sample for UpdatePhraseMatcher", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdatePhraseMatcher_async", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 48, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 49, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_phrase_matcher", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdatePhraseMatcher", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "UpdatePhraseMatcher" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.UpdatePhraseMatcherRequest" + }, + { + "name": "phrase_matcher", + "type": "google.cloud.contact_center_insights_v1.types.PhraseMatcher" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", + "shortName": "update_phrase_matcher" + }, + "description": "Sample for UpdatePhraseMatcher", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdatePhraseMatcher_sync", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 48, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 49, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_settings", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateSettings", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "UpdateSettings" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.UpdateSettingsRequest" + }, + { + "name": "settings", + "type": "google.cloud.contact_center_insights_v1.types.Settings" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Settings", + "shortName": "update_settings" + }, + "description": "Sample for UpdateSettings", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_settings_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateSettings_async", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_settings_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_settings", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateSettings", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "UpdateSettings" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.UpdateSettingsRequest" + }, + { + "name": "settings", + "type": "google.cloud.contact_center_insights_v1.types.Settings" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.Settings", + "shortName": "update_settings" + }, + "description": "Sample for UpdateSettings", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_settings_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateSettings_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_settings_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_view", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateView", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "UpdateView" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.UpdateViewRequest" + }, + { + "name": "view", + "type": "google.cloud.contact_center_insights_v1.types.View" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.View", + "shortName": "update_view" + }, + "description": "Sample for UpdateView", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_view_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateView_async", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_view_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_view", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateView", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "UpdateView" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.UpdateViewRequest" + }, + { + "name": "view", + "type": "google.cloud.contact_center_insights_v1.types.View" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.contact_center_insights_v1.types.View", + "shortName": "update_view" + }, + "description": "Sample for UpdateView", + "file": "contactcenterinsights_v1_generated_contact_center_insights_update_view_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateView_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_update_view_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", + "shortName": "ContactCenterInsightsAsyncClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.upload_conversation", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UploadConversation", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "UploadConversation" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.UploadConversationRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "upload_conversation" + }, + "description": "Sample for UploadConversation", + "file": "contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UploadConversation_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", + "shortName": "ContactCenterInsightsClient" + }, + "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.upload_conversation", + "method": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UploadConversation", + "service": { + "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", + "shortName": "ContactCenterInsights" + }, + "shortName": "UploadConversation" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.contact_center_insights_v1.types.UploadConversationRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "upload_conversation" + }, + "description": "Sample for UploadConversation", + "file": "contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UploadConversation_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_sync.py" + } + ] +} diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/scripts/fixup_contact_center_insights_v1_keywords.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/scripts/fixup_contact_center_insights_v1_keywords.py new file mode 100644 index 000000000000..6c0a0dd4ff19 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/scripts/fixup_contact_center_insights_v1_keywords.py @@ -0,0 +1,213 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2023 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 argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class contact_center_insightsCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'bulk_analyze_conversations': ('parent', 'filter', 'analysis_percentage', 'annotator_selector', ), + 'calculate_issue_model_stats': ('issue_model', ), + 'calculate_stats': ('location', 'filter', ), + 'create_analysis': ('parent', 'analysis', ), + 'create_conversation': ('parent', 'conversation', 'conversation_id', ), + 'create_issue_model': ('parent', 'issue_model', ), + 'create_phrase_matcher': ('parent', 'phrase_matcher', ), + 'create_view': ('parent', 'view', ), + 'delete_analysis': ('name', ), + 'delete_conversation': ('name', 'force', ), + 'delete_issue': ('name', ), + 'delete_issue_model': ('name', ), + 'delete_phrase_matcher': ('name', ), + 'delete_view': ('name', ), + 'deploy_issue_model': ('name', ), + 'export_insights_data': ('parent', 'big_query_destination', 'filter', 'kms_key', 'write_disposition', ), + 'get_analysis': ('name', ), + 'get_conversation': ('name', 'view', ), + 'get_issue': ('name', ), + 'get_issue_model': ('name', ), + 'get_phrase_matcher': ('name', ), + 'get_settings': ('name', ), + 'get_view': ('name', ), + 'ingest_conversations': ('parent', 'gcs_source', 'transcript_object_config', 'conversation_config', ), + 'list_analyses': ('parent', 'page_size', 'page_token', 'filter', ), + 'list_conversations': ('parent', 'page_size', 'page_token', 'filter', 'view', ), + 'list_issue_models': ('parent', ), + 'list_issues': ('parent', ), + 'list_phrase_matchers': ('parent', 'page_size', 'page_token', 'filter', ), + 'list_views': ('parent', 'page_size', 'page_token', ), + 'undeploy_issue_model': ('name', ), + 'update_conversation': ('conversation', 'update_mask', ), + 'update_issue': ('issue', 'update_mask', ), + 'update_issue_model': ('issue_model', 'update_mask', ), + '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', 'speech_config', ), + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: a.keyword.value not in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=contact_center_insightsCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the contact_center_insights client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/setup.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/setup.py new file mode 100644 index 000000000000..e09f76c7d733 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/setup.py @@ -0,0 +1,90 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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 io +import os + +import setuptools # type: ignore + +package_root = os.path.abspath(os.path.dirname(__file__)) + +name = 'google-cloud-contact-center-insights' + + +description = "Google Cloud Contact Center Insights API client library" + +version = {} +with open(os.path.join(package_root, 'google/cloud/contact_center_insights/gapic_version.py')) as fp: + exec(fp.read(), version) +version = version["__version__"] + +if version[0] == "0": + release_status = "Development Status :: 4 - Beta" +else: + release_status = "Development Status :: 5 - Production/Stable" + +dependencies = [ + "google-api-core[grpc] >= 1.34.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*", + "proto-plus >= 1.22.0, <2.0.0dev", + "proto-plus >= 1.22.2, <2.0.0dev; python_version>='3.11'", + "protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", +] +url = "https://github.com/googleapis/python-contact-center-insights" + +package_root = os.path.abspath(os.path.dirname(__file__)) + +readme_filename = os.path.join(package_root, "README.rst") +with io.open(readme_filename, encoding="utf-8") as readme_file: + readme = readme_file.read() + +packages = [ + package + for package in setuptools.PEP420PackageFinder.find() + if package.startswith("google") +] + +namespaces = ["google", "google.cloud"] + +setuptools.setup( + name=name, + version=version, + description=description, + long_description=readme, + author="Google LLC", + author_email="googleapis-packages@google.com", + license="Apache 2.0", + url=url, + classifiers=[ + release_status, + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Operating System :: OS Independent", + "Topic :: Internet", + ], + platforms="Posix; MacOS X; Windows", + packages=packages, + python_requires=">=3.7", + namespace_packages=namespaces, + install_requires=dependencies, + include_package_data=True, + zip_safe=False, +) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.10.txt b/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.10.txt new file mode 100644 index 000000000000..ed7f9aed2559 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.10.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.11.txt b/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.11.txt new file mode 100644 index 000000000000..ed7f9aed2559 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.11.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.12.txt b/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.12.txt new file mode 100644 index 000000000000..ed7f9aed2559 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.12.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.7.txt b/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.7.txt new file mode 100644 index 000000000000..6c44adfea7ee --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.7.txt @@ -0,0 +1,9 @@ +# This constraints file is used to check that lower bounds +# are correct in setup.py +# List all library dependencies and extras in this file. +# Pin the version to the lower bound. +# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", +# Then this file should have google-cloud-foo==1.14.0 +google-api-core==1.34.0 +proto-plus==1.22.0 +protobuf==3.19.5 diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.8.txt b/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.8.txt new file mode 100644 index 000000000000..ed7f9aed2559 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.8.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.9.txt b/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.9.txt new file mode 100644 index 000000000000..ed7f9aed2559 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.9.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/__init__.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/__init__.py new file mode 100644 index 000000000000..1b4db446eb8d --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/__init__.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/__init__.py new file mode 100644 index 000000000000..1b4db446eb8d --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/__init__.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/__init__.py new file mode 100644 index 000000000000..1b4db446eb8d --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/contact_center_insights_v1/__init__.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/contact_center_insights_v1/__init__.py new file mode 100644 index 000000000000..1b4db446eb8d --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/contact_center_insights_v1/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2023 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. +# diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py new file mode 100644 index 000000000000..8fa93fe59a94 --- /dev/null +++ b/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py @@ -0,0 +1,21043 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 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 os +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock # pragma: NO COVER +except ImportError: # pragma: NO COVER + import mock + +import grpc +from grpc.experimental import aio +from collections.abc import Iterable +from google.protobuf import json_format +import json +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule +from proto.marshal.rules import wrappers +from requests import Response +from requests import Request, PreparedRequest +from requests.sessions import Session +from google.protobuf import json_format + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import future +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers +from google.api_core import grpc_helpers_async +from google.api_core import operation +from google.api_core import operation_async # type: ignore +from google.api_core import operations_v1 +from google.api_core import path_template +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.contact_center_insights_v1.services.contact_center_insights import ContactCenterInsightsAsyncClient +from google.cloud.contact_center_insights_v1.services.contact_center_insights import ContactCenterInsightsClient +from google.cloud.contact_center_insights_v1.services.contact_center_insights import pagers +from google.cloud.contact_center_insights_v1.services.contact_center_insights import transports +from google.cloud.contact_center_insights_v1.types import contact_center_insights +from google.cloud.contact_center_insights_v1.types import resources +from google.longrunning import operations_pb2 # type: ignore +from google.oauth2 import service_account +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +def client_cert_source_callback(): + return b"cert bytes", b"key bytes" + + +# If default endpoint is localhost, then default mtls endpoint will be the same. +# This method modifies the default endpoint so the client can produce a different +# mtls endpoint for endpoint testing purposes. +def modify_default_endpoint(client): + return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT + + +def test__get_default_mtls_endpoint(): + api_endpoint = "example.googleapis.com" + api_mtls_endpoint = "example.mtls.googleapis.com" + sandbox_endpoint = "example.sandbox.googleapis.com" + sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" + non_googleapi = "api.example.com" + + assert ContactCenterInsightsClient._get_default_mtls_endpoint(None) is None + assert ContactCenterInsightsClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert ContactCenterInsightsClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert ContactCenterInsightsClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert ContactCenterInsightsClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert ContactCenterInsightsClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class,transport_name", [ + (ContactCenterInsightsClient, "grpc"), + (ContactCenterInsightsAsyncClient, "grpc_asyncio"), + (ContactCenterInsightsClient, "rest"), +]) +def test_contact_center_insights_client_from_service_account_info(client_class, transport_name): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: + factory.return_value = creds + info = {"valid": True} + client = client_class.from_service_account_info(info, transport=transport_name) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == ( + 'contactcenterinsights.googleapis.com:443' + if transport_name in ['grpc', 'grpc_asyncio'] + else + 'https://contactcenterinsights.googleapis.com' + ) + + +@pytest.mark.parametrize("transport_class,transport_name", [ + (transports.ContactCenterInsightsGrpcTransport, "grpc"), + (transports.ContactCenterInsightsGrpcAsyncIOTransport, "grpc_asyncio"), + (transports.ContactCenterInsightsRestTransport, "rest"), +]) +def test_contact_center_insights_client_service_account_always_use_jwt(transport_class, transport_name): + with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=True) + use_jwt.assert_called_once_with(True) + + with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=False) + use_jwt.assert_not_called() + + +@pytest.mark.parametrize("client_class,transport_name", [ + (ContactCenterInsightsClient, "grpc"), + (ContactCenterInsightsAsyncClient, "grpc_asyncio"), + (ContactCenterInsightsClient, "rest"), +]) +def test_contact_center_insights_client_from_service_account_file(client_class, transport_name): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory: + factory.return_value = creds + client = client_class.from_service_account_file("dummy/file/path.json", transport=transport_name) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + client = client_class.from_service_account_json("dummy/file/path.json", transport=transport_name) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == ( + 'contactcenterinsights.googleapis.com:443' + if transport_name in ['grpc', 'grpc_asyncio'] + else + 'https://contactcenterinsights.googleapis.com' + ) + + +def test_contact_center_insights_client_get_transport_class(): + transport = ContactCenterInsightsClient.get_transport_class() + available_transports = [ + transports.ContactCenterInsightsGrpcTransport, + transports.ContactCenterInsightsRestTransport, + ] + assert transport in available_transports + + transport = ContactCenterInsightsClient.get_transport_class("grpc") + assert transport == transports.ContactCenterInsightsGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (ContactCenterInsightsClient, transports.ContactCenterInsightsGrpcTransport, "grpc"), + (ContactCenterInsightsAsyncClient, transports.ContactCenterInsightsGrpcAsyncIOTransport, "grpc_asyncio"), + (ContactCenterInsightsClient, transports.ContactCenterInsightsRestTransport, "rest"), +]) +@mock.patch.object(ContactCenterInsightsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ContactCenterInsightsClient)) +@mock.patch.object(ContactCenterInsightsAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ContactCenterInsightsAsyncClient)) +def test_contact_center_insights_client_client_options(client_class, transport_class, transport_name): + # Check that if channel is provided we won't create a new one. + with mock.patch.object(ContactCenterInsightsClient, 'get_transport_class') as gtc: + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ) + client = client_class(transport=transport) + gtc.assert_not_called() + + # Check that if channel is provided via str we will create a new one. + with mock.patch.object(ContactCenterInsightsClient, 'get_transport_class') as gtc: + client = client_class(transport=transport_name) + gtc.assert_called() + + # Check the case api_endpoint is provided. + options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(transport=transport_name, client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has + # unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): + with pytest.raises(MutualTLSChannelError): + client = client_class(transport=transport_name) + + # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): + with pytest.raises(ValueError): + client = client_class(transport=transport_name) + + # Check the case quota_project_id is provided + options = client_options.ClientOptions(quota_project_id="octopus") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id="octopus", + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + # Check the case api_endpoint is provided + options = client_options.ClientOptions(api_audience="https://language.googleapis.com") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience="https://language.googleapis.com" + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (ContactCenterInsightsClient, transports.ContactCenterInsightsGrpcTransport, "grpc", "true"), + (ContactCenterInsightsAsyncClient, transports.ContactCenterInsightsGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (ContactCenterInsightsClient, transports.ContactCenterInsightsGrpcTransport, "grpc", "false"), + (ContactCenterInsightsAsyncClient, transports.ContactCenterInsightsGrpcAsyncIOTransport, "grpc_asyncio", "false"), + (ContactCenterInsightsClient, transports.ContactCenterInsightsRestTransport, "rest", "true"), + (ContactCenterInsightsClient, transports.ContactCenterInsightsRestTransport, "rest", "false"), +]) +@mock.patch.object(ContactCenterInsightsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ContactCenterInsightsClient)) +@mock.patch.object(ContactCenterInsightsAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ContactCenterInsightsAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_contact_center_insights_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): + # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default + # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. + + # Check the case client_cert_source is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + + if use_client_cert_env == "false": + expected_client_cert_source = None + expected_host = client.DEFAULT_ENDPOINT + else: + expected_client_cert_source = client_cert_source_callback + expected_host = client.DEFAULT_MTLS_ENDPOINT + + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # Check the case ADC client cert is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): + with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): + if use_client_cert_env == "false": + expected_host = client.DEFAULT_ENDPOINT + expected_client_cert_source = None + else: + expected_host = client.DEFAULT_MTLS_ENDPOINT + expected_client_cert_source = client_cert_source_callback + + patched.return_value = None + client = client_class(transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # Check the case client_cert_source and ADC client cert are not provided. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): + patched.return_value = None + client = client_class(transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class", [ + ContactCenterInsightsClient, ContactCenterInsightsAsyncClient +]) +@mock.patch.object(ContactCenterInsightsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ContactCenterInsightsClient)) +@mock.patch.object(ContactCenterInsightsAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ContactCenterInsightsAsyncClient)) +def test_contact_center_insights_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(options) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(options) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=False): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): + with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=mock_client_cert_source): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (ContactCenterInsightsClient, transports.ContactCenterInsightsGrpcTransport, "grpc"), + (ContactCenterInsightsAsyncClient, transports.ContactCenterInsightsGrpcAsyncIOTransport, "grpc_asyncio"), + (ContactCenterInsightsClient, transports.ContactCenterInsightsRestTransport, "rest"), +]) +def test_contact_center_insights_client_client_options_scopes(client_class, transport_class, transport_name): + # Check the case scopes are provided. + options = client_options.ClientOptions( + scopes=["1", "2"], + ) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=["1", "2"], + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (ContactCenterInsightsClient, transports.ContactCenterInsightsGrpcTransport, "grpc", grpc_helpers), + (ContactCenterInsightsAsyncClient, transports.ContactCenterInsightsGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), + (ContactCenterInsightsClient, transports.ContactCenterInsightsRestTransport, "rest", None), +]) +def test_contact_center_insights_client_client_options_credentials_file(client_class, transport_class, transport_name, grpc_helpers): + # Check the case credentials file is provided. + options = client_options.ClientOptions( + credentials_file="credentials.json" + ) + + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + +def test_contact_center_insights_client_client_options_from_dict(): + with mock.patch('google.cloud.contact_center_insights_v1.services.contact_center_insights.transports.ContactCenterInsightsGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = ContactCenterInsightsClient( + client_options={'api_endpoint': 'squid.clam.whelk'} + ) + grpc_transport.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (ContactCenterInsightsClient, transports.ContactCenterInsightsGrpcTransport, "grpc", grpc_helpers), + (ContactCenterInsightsAsyncClient, transports.ContactCenterInsightsGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_contact_center_insights_client_create_channel_credentials_file(client_class, transport_class, transport_name, grpc_helpers): + # Check the case credentials file is provided. + options = client_options.ClientOptions( + credentials_file="credentials.json" + ) + + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "contactcenterinsights.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + scopes=None, + default_host="contactcenterinsights.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.CreateConversationRequest, + dict, +]) +def test_create_conversation(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Conversation( + name='name_value', + language_code='language_code_value', + agent_id='agent_id_value', + medium=resources.Conversation.Medium.PHONE_CALL, + turn_count=1105, + obfuscated_user_id='obfuscated_user_id_value', + ) + response = client.create_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateConversationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Conversation) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + assert response.agent_id == 'agent_id_value' + assert response.medium == resources.Conversation.Medium.PHONE_CALL + assert response.turn_count == 1105 + assert response.obfuscated_user_id == 'obfuscated_user_id_value' + + +def test_create_conversation_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversation), + '__call__') as call: + client.create_conversation() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateConversationRequest() + +@pytest.mark.asyncio +async def test_create_conversation_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.CreateConversationRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation( + name='name_value', + language_code='language_code_value', + agent_id='agent_id_value', + medium=resources.Conversation.Medium.PHONE_CALL, + turn_count=1105, + obfuscated_user_id='obfuscated_user_id_value', + )) + response = await client.create_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateConversationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Conversation) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + assert response.agent_id == 'agent_id_value' + assert response.medium == resources.Conversation.Medium.PHONE_CALL + assert response.turn_count == 1105 + assert response.obfuscated_user_id == 'obfuscated_user_id_value' + + +@pytest.mark.asyncio +async def test_create_conversation_async_from_dict(): + await test_create_conversation_async(request_type=dict) + + +def test_create_conversation_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateConversationRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversation), + '__call__') as call: + call.return_value = resources.Conversation() + client.create_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_create_conversation_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateConversationRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversation), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation()) + await client.create_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_create_conversation_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Conversation() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_conversation( + parent='parent_value', + conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), + conversation_id='conversation_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].conversation + mock_val = resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)) + assert arg == mock_val + arg = args[0].conversation_id + mock_val = 'conversation_id_value' + assert arg == mock_val + + +def test_create_conversation_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_conversation( + contact_center_insights.CreateConversationRequest(), + parent='parent_value', + conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), + conversation_id='conversation_id_value', + ) + +@pytest.mark.asyncio +async def test_create_conversation_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Conversation() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_conversation( + parent='parent_value', + conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), + conversation_id='conversation_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].conversation + mock_val = resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)) + assert arg == mock_val + arg = args[0].conversation_id + mock_val = 'conversation_id_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_conversation_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_conversation( + contact_center_insights.CreateConversationRequest(), + parent='parent_value', + conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), + conversation_id='conversation_id_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UploadConversationRequest, + dict, +]) +def test_upload_conversation(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.upload_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.upload_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UploadConversationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_upload_conversation_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.upload_conversation), + '__call__') as call: + client.upload_conversation() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UploadConversationRequest() + +@pytest.mark.asyncio +async def test_upload_conversation_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UploadConversationRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.upload_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.upload_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UploadConversationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_upload_conversation_async_from_dict(): + await test_upload_conversation_async(request_type=dict) + + +def test_upload_conversation_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UploadConversationRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.upload_conversation), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.upload_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_upload_conversation_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UploadConversationRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.upload_conversation), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.upload_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UpdateConversationRequest, + dict, +]) +def test_update_conversation(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Conversation( + name='name_value', + language_code='language_code_value', + agent_id='agent_id_value', + medium=resources.Conversation.Medium.PHONE_CALL, + turn_count=1105, + obfuscated_user_id='obfuscated_user_id_value', + ) + response = client.update_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateConversationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Conversation) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + assert response.agent_id == 'agent_id_value' + assert response.medium == resources.Conversation.Medium.PHONE_CALL + assert response.turn_count == 1105 + assert response.obfuscated_user_id == 'obfuscated_user_id_value' + + +def test_update_conversation_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_conversation), + '__call__') as call: + client.update_conversation() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateConversationRequest() + +@pytest.mark.asyncio +async def test_update_conversation_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UpdateConversationRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation( + name='name_value', + language_code='language_code_value', + agent_id='agent_id_value', + medium=resources.Conversation.Medium.PHONE_CALL, + turn_count=1105, + obfuscated_user_id='obfuscated_user_id_value', + )) + response = await client.update_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateConversationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Conversation) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + assert response.agent_id == 'agent_id_value' + assert response.medium == resources.Conversation.Medium.PHONE_CALL + assert response.turn_count == 1105 + assert response.obfuscated_user_id == 'obfuscated_user_id_value' + + +@pytest.mark.asyncio +async def test_update_conversation_async_from_dict(): + await test_update_conversation_async(request_type=dict) + + +def test_update_conversation_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateConversationRequest() + + request.conversation.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_conversation), + '__call__') as call: + call.return_value = resources.Conversation() + client.update_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'conversation.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_conversation_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateConversationRequest() + + request.conversation.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_conversation), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation()) + await client.update_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'conversation.name=name_value', + ) in kw['metadata'] + + +def test_update_conversation_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Conversation() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_conversation( + conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].conversation + mock_val = resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)) + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_conversation_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_conversation( + contact_center_insights.UpdateConversationRequest(), + conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_conversation_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Conversation() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_conversation( + conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].conversation + mock_val = resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)) + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + +@pytest.mark.asyncio +async def test_update_conversation_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_conversation( + contact_center_insights.UpdateConversationRequest(), + conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.GetConversationRequest, + dict, +]) +def test_get_conversation(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Conversation( + name='name_value', + language_code='language_code_value', + agent_id='agent_id_value', + medium=resources.Conversation.Medium.PHONE_CALL, + turn_count=1105, + obfuscated_user_id='obfuscated_user_id_value', + ) + response = client.get_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetConversationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Conversation) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + assert response.agent_id == 'agent_id_value' + assert response.medium == resources.Conversation.Medium.PHONE_CALL + assert response.turn_count == 1105 + assert response.obfuscated_user_id == 'obfuscated_user_id_value' + + +def test_get_conversation_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversation), + '__call__') as call: + client.get_conversation() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetConversationRequest() + +@pytest.mark.asyncio +async def test_get_conversation_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.GetConversationRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation( + name='name_value', + language_code='language_code_value', + agent_id='agent_id_value', + medium=resources.Conversation.Medium.PHONE_CALL, + turn_count=1105, + obfuscated_user_id='obfuscated_user_id_value', + )) + response = await client.get_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetConversationRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Conversation) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + assert response.agent_id == 'agent_id_value' + assert response.medium == resources.Conversation.Medium.PHONE_CALL + assert response.turn_count == 1105 + assert response.obfuscated_user_id == 'obfuscated_user_id_value' + + +@pytest.mark.asyncio +async def test_get_conversation_async_from_dict(): + await test_get_conversation_async(request_type=dict) + + +def test_get_conversation_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetConversationRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversation), + '__call__') as call: + call.return_value = resources.Conversation() + client.get_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_get_conversation_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetConversationRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversation), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation()) + await client.get_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_get_conversation_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Conversation() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_conversation( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_conversation_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_conversation( + contact_center_insights.GetConversationRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_conversation_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Conversation() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_conversation( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_get_conversation_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_conversation( + contact_center_insights.GetConversationRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.ListConversationsRequest, + dict, +]) +def test_list_conversations(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversations), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListConversationsResponse( + next_page_token='next_page_token_value', + ) + response = client.list_conversations(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListConversationsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListConversationsPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_conversations_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversations), + '__call__') as call: + client.list_conversations() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListConversationsRequest() + +@pytest.mark.asyncio +async def test_list_conversations_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.ListConversationsRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversations), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListConversationsResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_conversations(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListConversationsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListConversationsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_conversations_async_from_dict(): + await test_list_conversations_async(request_type=dict) + + +def test_list_conversations_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListConversationsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversations), + '__call__') as call: + call.return_value = contact_center_insights.ListConversationsResponse() + client.list_conversations(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_list_conversations_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListConversationsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversations), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListConversationsResponse()) + await client.list_conversations(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_list_conversations_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversations), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListConversationsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_conversations( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_conversations_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_conversations( + contact_center_insights.ListConversationsRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_conversations_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversations), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListConversationsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListConversationsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_conversations( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_list_conversations_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_conversations( + contact_center_insights.ListConversationsRequest(), + parent='parent_value', + ) + + +def test_list_conversations_pager(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversations), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + resources.Conversation(), + resources.Conversation(), + ], + next_page_token='abc', + ), + contact_center_insights.ListConversationsResponse( + conversations=[], + next_page_token='def', + ), + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + resources.Conversation(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_conversations(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.Conversation) + for i in results) +def test_list_conversations_pages(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversations), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + resources.Conversation(), + resources.Conversation(), + ], + next_page_token='abc', + ), + contact_center_insights.ListConversationsResponse( + conversations=[], + next_page_token='def', + ), + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + resources.Conversation(), + ], + ), + RuntimeError, + ) + pages = list(client.list_conversations(request={}).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.asyncio +async def test_list_conversations_async_pager(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversations), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + resources.Conversation(), + resources.Conversation(), + ], + next_page_token='abc', + ), + contact_center_insights.ListConversationsResponse( + conversations=[], + next_page_token='def', + ), + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + resources.Conversation(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_conversations(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.Conversation) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_conversations_async_pages(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_conversations), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + resources.Conversation(), + resources.Conversation(), + ], + next_page_token='abc', + ), + contact_center_insights.ListConversationsResponse( + conversations=[], + next_page_token='def', + ), + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + resources.Conversation(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_conversations(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.DeleteConversationRequest, + dict, +]) +def test_delete_conversation(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteConversationRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_conversation_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversation), + '__call__') as call: + client.delete_conversation() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteConversationRequest() + +@pytest.mark.asyncio +async def test_delete_conversation_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.DeleteConversationRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteConversationRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_conversation_async_from_dict(): + await test_delete_conversation_async(request_type=dict) + + +def test_delete_conversation_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteConversationRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversation), + '__call__') as call: + call.return_value = None + client.delete_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_delete_conversation_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteConversationRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversation), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_conversation(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_delete_conversation_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_conversation( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_delete_conversation_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_conversation( + contact_center_insights.DeleteConversationRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_conversation_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_conversation), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_conversation( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_delete_conversation_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_conversation( + contact_center_insights.DeleteConversationRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.CreateAnalysisRequest, + dict, +]) +def test_create_analysis(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_analysis), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateAnalysisRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_analysis_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_analysis), + '__call__') as call: + client.create_analysis() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateAnalysisRequest() + +@pytest.mark.asyncio +async def test_create_analysis_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.CreateAnalysisRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_analysis), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.create_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateAnalysisRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_analysis_async_from_dict(): + await test_create_analysis_async(request_type=dict) + + +def test_create_analysis_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateAnalysisRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_analysis), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_create_analysis_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateAnalysisRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_analysis), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_create_analysis_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_analysis), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_analysis( + parent='parent_value', + analysis=resources.Analysis(name='name_value'), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].analysis + mock_val = resources.Analysis(name='name_value') + assert arg == mock_val + + +def test_create_analysis_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_analysis( + contact_center_insights.CreateAnalysisRequest(), + parent='parent_value', + analysis=resources.Analysis(name='name_value'), + ) + +@pytest.mark.asyncio +async def test_create_analysis_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_analysis), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_analysis( + parent='parent_value', + analysis=resources.Analysis(name='name_value'), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].analysis + mock_val = resources.Analysis(name='name_value') + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_analysis_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_analysis( + contact_center_insights.CreateAnalysisRequest(), + parent='parent_value', + analysis=resources.Analysis(name='name_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.GetAnalysisRequest, + dict, +]) +def test_get_analysis(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_analysis), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Analysis( + name='name_value', + ) + response = client.get_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetAnalysisRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Analysis) + assert response.name == 'name_value' + + +def test_get_analysis_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_analysis), + '__call__') as call: + client.get_analysis() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetAnalysisRequest() + +@pytest.mark.asyncio +async def test_get_analysis_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.GetAnalysisRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_analysis), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Analysis( + name='name_value', + )) + response = await client.get_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetAnalysisRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Analysis) + assert response.name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_analysis_async_from_dict(): + await test_get_analysis_async(request_type=dict) + + +def test_get_analysis_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetAnalysisRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_analysis), + '__call__') as call: + call.return_value = resources.Analysis() + client.get_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_get_analysis_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetAnalysisRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_analysis), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Analysis()) + await client.get_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_get_analysis_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_analysis), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Analysis() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_analysis( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_analysis_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_analysis( + contact_center_insights.GetAnalysisRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_analysis_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_analysis), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Analysis() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Analysis()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_analysis( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_get_analysis_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_analysis( + contact_center_insights.GetAnalysisRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.ListAnalysesRequest, + dict, +]) +def test_list_analyses(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analyses), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListAnalysesResponse( + next_page_token='next_page_token_value', + ) + response = client.list_analyses(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListAnalysesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListAnalysesPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_analyses_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analyses), + '__call__') as call: + client.list_analyses() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListAnalysesRequest() + +@pytest.mark.asyncio +async def test_list_analyses_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.ListAnalysesRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analyses), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListAnalysesResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_analyses(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListAnalysesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListAnalysesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_analyses_async_from_dict(): + await test_list_analyses_async(request_type=dict) + + +def test_list_analyses_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListAnalysesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analyses), + '__call__') as call: + call.return_value = contact_center_insights.ListAnalysesResponse() + client.list_analyses(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_list_analyses_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListAnalysesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analyses), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListAnalysesResponse()) + await client.list_analyses(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_list_analyses_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analyses), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListAnalysesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_analyses( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_analyses_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_analyses( + contact_center_insights.ListAnalysesRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_analyses_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analyses), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListAnalysesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListAnalysesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_analyses( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_list_analyses_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_analyses( + contact_center_insights.ListAnalysesRequest(), + parent='parent_value', + ) + + +def test_list_analyses_pager(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analyses), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + resources.Analysis(), + resources.Analysis(), + ], + next_page_token='abc', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[], + next_page_token='def', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + resources.Analysis(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_analyses(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.Analysis) + for i in results) +def test_list_analyses_pages(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analyses), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + resources.Analysis(), + resources.Analysis(), + ], + next_page_token='abc', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[], + next_page_token='def', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + resources.Analysis(), + ], + ), + RuntimeError, + ) + pages = list(client.list_analyses(request={}).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.asyncio +async def test_list_analyses_async_pager(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analyses), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + resources.Analysis(), + resources.Analysis(), + ], + next_page_token='abc', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[], + next_page_token='def', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + resources.Analysis(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_analyses(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.Analysis) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_analyses_async_pages(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_analyses), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + resources.Analysis(), + resources.Analysis(), + ], + next_page_token='abc', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[], + next_page_token='def', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + resources.Analysis(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_analyses(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.DeleteAnalysisRequest, + dict, +]) +def test_delete_analysis(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_analysis), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteAnalysisRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_analysis_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_analysis), + '__call__') as call: + client.delete_analysis() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteAnalysisRequest() + +@pytest.mark.asyncio +async def test_delete_analysis_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.DeleteAnalysisRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_analysis), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteAnalysisRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_analysis_async_from_dict(): + await test_delete_analysis_async(request_type=dict) + + +def test_delete_analysis_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteAnalysisRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_analysis), + '__call__') as call: + call.return_value = None + client.delete_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_delete_analysis_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteAnalysisRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_analysis), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_analysis(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_delete_analysis_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_analysis), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_analysis( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_delete_analysis_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_analysis( + contact_center_insights.DeleteAnalysisRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_analysis_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_analysis), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_analysis( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_delete_analysis_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_analysis( + contact_center_insights.DeleteAnalysisRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.BulkAnalyzeConversationsRequest, + dict, +]) +def test_bulk_analyze_conversations(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.bulk_analyze_conversations), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.bulk_analyze_conversations(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.BulkAnalyzeConversationsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_bulk_analyze_conversations_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.bulk_analyze_conversations), + '__call__') as call: + client.bulk_analyze_conversations() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.BulkAnalyzeConversationsRequest() + +@pytest.mark.asyncio +async def test_bulk_analyze_conversations_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.BulkAnalyzeConversationsRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.bulk_analyze_conversations), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.bulk_analyze_conversations(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.BulkAnalyzeConversationsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_bulk_analyze_conversations_async_from_dict(): + await test_bulk_analyze_conversations_async(request_type=dict) + + +def test_bulk_analyze_conversations_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.BulkAnalyzeConversationsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.bulk_analyze_conversations), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.bulk_analyze_conversations(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_bulk_analyze_conversations_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.BulkAnalyzeConversationsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.bulk_analyze_conversations), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.bulk_analyze_conversations(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_bulk_analyze_conversations_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.bulk_analyze_conversations), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.bulk_analyze_conversations( + parent='parent_value', + filter='filter_value', + analysis_percentage=0.20170000000000002, + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].filter + mock_val = 'filter_value' + assert arg == mock_val + assert math.isclose(args[0].analysis_percentage, 0.20170000000000002, rel_tol=1e-6) + + +def test_bulk_analyze_conversations_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.bulk_analyze_conversations( + contact_center_insights.BulkAnalyzeConversationsRequest(), + parent='parent_value', + filter='filter_value', + analysis_percentage=0.20170000000000002, + ) + +@pytest.mark.asyncio +async def test_bulk_analyze_conversations_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.bulk_analyze_conversations), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.bulk_analyze_conversations( + parent='parent_value', + filter='filter_value', + analysis_percentage=0.20170000000000002, + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].filter + mock_val = 'filter_value' + assert arg == mock_val + assert math.isclose(args[0].analysis_percentage, 0.20170000000000002, rel_tol=1e-6) + +@pytest.mark.asyncio +async def test_bulk_analyze_conversations_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.bulk_analyze_conversations( + contact_center_insights.BulkAnalyzeConversationsRequest(), + parent='parent_value', + filter='filter_value', + analysis_percentage=0.20170000000000002, + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.IngestConversationsRequest, + dict, +]) +def test_ingest_conversations(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.ingest_conversations), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.ingest_conversations(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.IngestConversationsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_ingest_conversations_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.ingest_conversations), + '__call__') as call: + client.ingest_conversations() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.IngestConversationsRequest() + +@pytest.mark.asyncio +async def test_ingest_conversations_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.IngestConversationsRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.ingest_conversations), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.ingest_conversations(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.IngestConversationsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_ingest_conversations_async_from_dict(): + await test_ingest_conversations_async(request_type=dict) + + +def test_ingest_conversations_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.IngestConversationsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.ingest_conversations), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.ingest_conversations(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_ingest_conversations_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.IngestConversationsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.ingest_conversations), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.ingest_conversations(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_ingest_conversations_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.ingest_conversations), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.ingest_conversations( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_ingest_conversations_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.ingest_conversations( + contact_center_insights.IngestConversationsRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_ingest_conversations_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.ingest_conversations), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.ingest_conversations( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_ingest_conversations_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.ingest_conversations( + contact_center_insights.IngestConversationsRequest(), + parent='parent_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.ExportInsightsDataRequest, + dict, +]) +def test_export_insights_data(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.export_insights_data), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.export_insights_data(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ExportInsightsDataRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_export_insights_data_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.export_insights_data), + '__call__') as call: + client.export_insights_data() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ExportInsightsDataRequest() + +@pytest.mark.asyncio +async def test_export_insights_data_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.ExportInsightsDataRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.export_insights_data), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.export_insights_data(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ExportInsightsDataRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_export_insights_data_async_from_dict(): + await test_export_insights_data_async(request_type=dict) + + +def test_export_insights_data_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ExportInsightsDataRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.export_insights_data), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.export_insights_data(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_export_insights_data_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ExportInsightsDataRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.export_insights_data), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.export_insights_data(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_export_insights_data_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.export_insights_data), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.export_insights_data( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_export_insights_data_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.export_insights_data( + contact_center_insights.ExportInsightsDataRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_export_insights_data_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.export_insights_data), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.export_insights_data( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_export_insights_data_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.export_insights_data( + contact_center_insights.ExportInsightsDataRequest(), + parent='parent_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.CreateIssueModelRequest, + dict, +]) +def test_create_issue_model(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_issue_model_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_model), + '__call__') as call: + client.create_issue_model() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateIssueModelRequest() + +@pytest.mark.asyncio +async def test_create_issue_model_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.CreateIssueModelRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.create_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_issue_model_async_from_dict(): + await test_create_issue_model_async(request_type=dict) + + +def test_create_issue_model_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateIssueModelRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_model), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_create_issue_model_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateIssueModelRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_model), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_create_issue_model_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_issue_model( + parent='parent_value', + issue_model=resources.IssueModel(name='name_value'), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].issue_model + mock_val = resources.IssueModel(name='name_value') + assert arg == mock_val + + +def test_create_issue_model_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_issue_model( + contact_center_insights.CreateIssueModelRequest(), + parent='parent_value', + issue_model=resources.IssueModel(name='name_value'), + ) + +@pytest.mark.asyncio +async def test_create_issue_model_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_issue_model( + parent='parent_value', + issue_model=resources.IssueModel(name='name_value'), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].issue_model + mock_val = resources.IssueModel(name='name_value') + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_issue_model_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_issue_model( + contact_center_insights.CreateIssueModelRequest(), + parent='parent_value', + issue_model=resources.IssueModel(name='name_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UpdateIssueModelRequest, + dict, +]) +def test_update_issue_model(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IssueModel( + name='name_value', + display_name='display_name_value', + issue_count=1201, + state=resources.IssueModel.State.UNDEPLOYED, + model_type=resources.IssueModel.ModelType.TYPE_V1, + language_code='language_code_value', + ) + response = client.update_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.IssueModel) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.issue_count == 1201 + assert response.state == resources.IssueModel.State.UNDEPLOYED + assert response.model_type == resources.IssueModel.ModelType.TYPE_V1 + assert response.language_code == 'language_code_value' + + +def test_update_issue_model_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_model), + '__call__') as call: + client.update_issue_model() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateIssueModelRequest() + +@pytest.mark.asyncio +async def test_update_issue_model_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UpdateIssueModelRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.IssueModel( + name='name_value', + display_name='display_name_value', + issue_count=1201, + state=resources.IssueModel.State.UNDEPLOYED, + model_type=resources.IssueModel.ModelType.TYPE_V1, + language_code='language_code_value', + )) + response = await client.update_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.IssueModel) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.issue_count == 1201 + assert response.state == resources.IssueModel.State.UNDEPLOYED + assert response.model_type == resources.IssueModel.ModelType.TYPE_V1 + assert response.language_code == 'language_code_value' + + +@pytest.mark.asyncio +async def test_update_issue_model_async_from_dict(): + await test_update_issue_model_async(request_type=dict) + + +def test_update_issue_model_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateIssueModelRequest() + + request.issue_model.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_model), + '__call__') as call: + call.return_value = resources.IssueModel() + client.update_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'issue_model.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_issue_model_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateIssueModelRequest() + + request.issue_model.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_model), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IssueModel()) + await client.update_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'issue_model.name=name_value', + ) in kw['metadata'] + + +def test_update_issue_model_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IssueModel() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_issue_model( + issue_model=resources.IssueModel(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].issue_model + mock_val = resources.IssueModel(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_issue_model_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_issue_model( + contact_center_insights.UpdateIssueModelRequest(), + issue_model=resources.IssueModel(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_issue_model_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IssueModel() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IssueModel()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_issue_model( + issue_model=resources.IssueModel(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].issue_model + mock_val = resources.IssueModel(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + +@pytest.mark.asyncio +async def test_update_issue_model_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_issue_model( + contact_center_insights.UpdateIssueModelRequest(), + issue_model=resources.IssueModel(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.GetIssueModelRequest, + dict, +]) +def test_get_issue_model(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IssueModel( + name='name_value', + display_name='display_name_value', + issue_count=1201, + state=resources.IssueModel.State.UNDEPLOYED, + model_type=resources.IssueModel.ModelType.TYPE_V1, + language_code='language_code_value', + ) + response = client.get_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.IssueModel) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.issue_count == 1201 + assert response.state == resources.IssueModel.State.UNDEPLOYED + assert response.model_type == resources.IssueModel.ModelType.TYPE_V1 + assert response.language_code == 'language_code_value' + + +def test_get_issue_model_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue_model), + '__call__') as call: + client.get_issue_model() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetIssueModelRequest() + +@pytest.mark.asyncio +async def test_get_issue_model_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.GetIssueModelRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.IssueModel( + name='name_value', + display_name='display_name_value', + issue_count=1201, + state=resources.IssueModel.State.UNDEPLOYED, + model_type=resources.IssueModel.ModelType.TYPE_V1, + language_code='language_code_value', + )) + response = await client.get_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.IssueModel) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.issue_count == 1201 + assert response.state == resources.IssueModel.State.UNDEPLOYED + assert response.model_type == resources.IssueModel.ModelType.TYPE_V1 + assert response.language_code == 'language_code_value' + + +@pytest.mark.asyncio +async def test_get_issue_model_async_from_dict(): + await test_get_issue_model_async(request_type=dict) + + +def test_get_issue_model_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetIssueModelRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue_model), + '__call__') as call: + call.return_value = resources.IssueModel() + client.get_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_get_issue_model_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetIssueModelRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue_model), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IssueModel()) + await client.get_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_get_issue_model_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IssueModel() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_issue_model( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_issue_model_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_issue_model( + contact_center_insights.GetIssueModelRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_issue_model_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IssueModel() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IssueModel()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_issue_model( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_get_issue_model_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_issue_model( + contact_center_insights.GetIssueModelRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.ListIssueModelsRequest, + dict, +]) +def test_list_issue_models(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_models), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListIssueModelsResponse( + ) + response = client.list_issue_models(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListIssueModelsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.ListIssueModelsResponse) + + +def test_list_issue_models_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_models), + '__call__') as call: + client.list_issue_models() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListIssueModelsRequest() + +@pytest.mark.asyncio +async def test_list_issue_models_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.ListIssueModelsRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_models), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListIssueModelsResponse( + )) + response = await client.list_issue_models(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListIssueModelsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.ListIssueModelsResponse) + + +@pytest.mark.asyncio +async def test_list_issue_models_async_from_dict(): + await test_list_issue_models_async(request_type=dict) + + +def test_list_issue_models_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListIssueModelsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_models), + '__call__') as call: + call.return_value = contact_center_insights.ListIssueModelsResponse() + client.list_issue_models(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_list_issue_models_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListIssueModelsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_models), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListIssueModelsResponse()) + await client.list_issue_models(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_list_issue_models_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_models), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListIssueModelsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_issue_models( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_issue_models_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_issue_models( + contact_center_insights.ListIssueModelsRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_issue_models_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_models), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListIssueModelsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListIssueModelsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_issue_models( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_list_issue_models_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_issue_models( + contact_center_insights.ListIssueModelsRequest(), + parent='parent_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.DeleteIssueModelRequest, + dict, +]) +def test_delete_issue_model(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_issue_model_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_model), + '__call__') as call: + client.delete_issue_model() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteIssueModelRequest() + +@pytest.mark.asyncio +async def test_delete_issue_model_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.DeleteIssueModelRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.delete_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_issue_model_async_from_dict(): + await test_delete_issue_model_async(request_type=dict) + + +def test_delete_issue_model_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteIssueModelRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_model), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_delete_issue_model_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteIssueModelRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_model), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_delete_issue_model_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_issue_model( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_delete_issue_model_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_issue_model( + contact_center_insights.DeleteIssueModelRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_issue_model_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_issue_model( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_delete_issue_model_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_issue_model( + contact_center_insights.DeleteIssueModelRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.DeployIssueModelRequest, + dict, +]) +def test_deploy_issue_model(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deploy_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.deploy_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeployIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_deploy_issue_model_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deploy_issue_model), + '__call__') as call: + client.deploy_issue_model() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeployIssueModelRequest() + +@pytest.mark.asyncio +async def test_deploy_issue_model_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.DeployIssueModelRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deploy_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.deploy_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeployIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_deploy_issue_model_async_from_dict(): + await test_deploy_issue_model_async(request_type=dict) + + +def test_deploy_issue_model_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeployIssueModelRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deploy_issue_model), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.deploy_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_deploy_issue_model_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeployIssueModelRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deploy_issue_model), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.deploy_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_deploy_issue_model_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deploy_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.deploy_issue_model( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_deploy_issue_model_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.deploy_issue_model( + contact_center_insights.DeployIssueModelRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_deploy_issue_model_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deploy_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.deploy_issue_model( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_deploy_issue_model_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.deploy_issue_model( + contact_center_insights.DeployIssueModelRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UndeployIssueModelRequest, + dict, +]) +def test_undeploy_issue_model(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.undeploy_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UndeployIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_undeploy_issue_model_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_issue_model), + '__call__') as call: + client.undeploy_issue_model() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UndeployIssueModelRequest() + +@pytest.mark.asyncio +async def test_undeploy_issue_model_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UndeployIssueModelRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.undeploy_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UndeployIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_undeploy_issue_model_async_from_dict(): + await test_undeploy_issue_model_async(request_type=dict) + + +def test_undeploy_issue_model_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UndeployIssueModelRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_issue_model), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.undeploy_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_undeploy_issue_model_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UndeployIssueModelRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_issue_model), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.undeploy_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_undeploy_issue_model_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.undeploy_issue_model( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_undeploy_issue_model_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.undeploy_issue_model( + contact_center_insights.UndeployIssueModelRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_undeploy_issue_model_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.undeploy_issue_model), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.undeploy_issue_model( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_undeploy_issue_model_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.undeploy_issue_model( + contact_center_insights.UndeployIssueModelRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.GetIssueRequest, + dict, +]) +def test_get_issue(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Issue( + name='name_value', + display_name='display_name_value', + sample_utterances=['sample_utterances_value'], + ) + response = client.get_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetIssueRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Issue) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.sample_utterances == ['sample_utterances_value'] + + +def test_get_issue_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue), + '__call__') as call: + client.get_issue() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetIssueRequest() + +@pytest.mark.asyncio +async def test_get_issue_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.GetIssueRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Issue( + name='name_value', + display_name='display_name_value', + sample_utterances=['sample_utterances_value'], + )) + response = await client.get_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetIssueRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Issue) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.sample_utterances == ['sample_utterances_value'] + + +@pytest.mark.asyncio +async def test_get_issue_async_from_dict(): + await test_get_issue_async(request_type=dict) + + +def test_get_issue_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetIssueRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue), + '__call__') as call: + call.return_value = resources.Issue() + client.get_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_get_issue_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetIssueRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Issue()) + await client.get_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_get_issue_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Issue() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_issue( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_issue_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_issue( + contact_center_insights.GetIssueRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_issue_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Issue() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Issue()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_issue( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_get_issue_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_issue( + contact_center_insights.GetIssueRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.ListIssuesRequest, + dict, +]) +def test_list_issues(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issues), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListIssuesResponse( + ) + response = client.list_issues(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListIssuesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.ListIssuesResponse) + + +def test_list_issues_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issues), + '__call__') as call: + client.list_issues() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListIssuesRequest() + +@pytest.mark.asyncio +async def test_list_issues_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.ListIssuesRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issues), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListIssuesResponse( + )) + response = await client.list_issues(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListIssuesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.ListIssuesResponse) + + +@pytest.mark.asyncio +async def test_list_issues_async_from_dict(): + await test_list_issues_async(request_type=dict) + + +def test_list_issues_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListIssuesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issues), + '__call__') as call: + call.return_value = contact_center_insights.ListIssuesResponse() + client.list_issues(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_list_issues_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListIssuesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issues), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListIssuesResponse()) + await client.list_issues(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_list_issues_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issues), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListIssuesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_issues( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_issues_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_issues( + contact_center_insights.ListIssuesRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_issues_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issues), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListIssuesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListIssuesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_issues( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_list_issues_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_issues( + contact_center_insights.ListIssuesRequest(), + parent='parent_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UpdateIssueRequest, + dict, +]) +def test_update_issue(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Issue( + name='name_value', + display_name='display_name_value', + sample_utterances=['sample_utterances_value'], + ) + response = client.update_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateIssueRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Issue) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.sample_utterances == ['sample_utterances_value'] + + +def test_update_issue_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue), + '__call__') as call: + client.update_issue() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateIssueRequest() + +@pytest.mark.asyncio +async def test_update_issue_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UpdateIssueRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Issue( + name='name_value', + display_name='display_name_value', + sample_utterances=['sample_utterances_value'], + )) + response = await client.update_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateIssueRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Issue) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.sample_utterances == ['sample_utterances_value'] + + +@pytest.mark.asyncio +async def test_update_issue_async_from_dict(): + await test_update_issue_async(request_type=dict) + + +def test_update_issue_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateIssueRequest() + + request.issue.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue), + '__call__') as call: + call.return_value = resources.Issue() + client.update_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'issue.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_issue_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateIssueRequest() + + request.issue.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Issue()) + await client.update_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'issue.name=name_value', + ) in kw['metadata'] + + +def test_update_issue_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Issue() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_issue( + issue=resources.Issue(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].issue + mock_val = resources.Issue(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_issue_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_issue( + contact_center_insights.UpdateIssueRequest(), + issue=resources.Issue(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_issue_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Issue() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Issue()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_issue( + issue=resources.Issue(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].issue + mock_val = resources.Issue(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + +@pytest.mark.asyncio +async def test_update_issue_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_issue( + contact_center_insights.UpdateIssueRequest(), + issue=resources.Issue(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.DeleteIssueRequest, + dict, +]) +def test_delete_issue(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteIssueRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_issue_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue), + '__call__') as call: + client.delete_issue() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteIssueRequest() + +@pytest.mark.asyncio +async def test_delete_issue_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.DeleteIssueRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteIssueRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_issue_async_from_dict(): + await test_delete_issue_async(request_type=dict) + + +def test_delete_issue_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteIssueRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue), + '__call__') as call: + call.return_value = None + client.delete_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_delete_issue_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteIssueRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_delete_issue_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_issue( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_delete_issue_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_issue( + contact_center_insights.DeleteIssueRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_issue_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_issue( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_delete_issue_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_issue( + contact_center_insights.DeleteIssueRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.CalculateIssueModelStatsRequest, + dict, +]) +def test_calculate_issue_model_stats(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_issue_model_stats), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.CalculateIssueModelStatsResponse( + ) + response = client.calculate_issue_model_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CalculateIssueModelStatsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.CalculateIssueModelStatsResponse) + + +def test_calculate_issue_model_stats_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_issue_model_stats), + '__call__') as call: + client.calculate_issue_model_stats() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CalculateIssueModelStatsRequest() + +@pytest.mark.asyncio +async def test_calculate_issue_model_stats_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.CalculateIssueModelStatsRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_issue_model_stats), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.CalculateIssueModelStatsResponse( + )) + response = await client.calculate_issue_model_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CalculateIssueModelStatsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.CalculateIssueModelStatsResponse) + + +@pytest.mark.asyncio +async def test_calculate_issue_model_stats_async_from_dict(): + await test_calculate_issue_model_stats_async(request_type=dict) + + +def test_calculate_issue_model_stats_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CalculateIssueModelStatsRequest() + + request.issue_model = 'issue_model_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_issue_model_stats), + '__call__') as call: + call.return_value = contact_center_insights.CalculateIssueModelStatsResponse() + client.calculate_issue_model_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'issue_model=issue_model_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_calculate_issue_model_stats_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CalculateIssueModelStatsRequest() + + request.issue_model = 'issue_model_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_issue_model_stats), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.CalculateIssueModelStatsResponse()) + await client.calculate_issue_model_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'issue_model=issue_model_value', + ) in kw['metadata'] + + +def test_calculate_issue_model_stats_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_issue_model_stats), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.CalculateIssueModelStatsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.calculate_issue_model_stats( + issue_model='issue_model_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].issue_model + mock_val = 'issue_model_value' + assert arg == mock_val + + +def test_calculate_issue_model_stats_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.calculate_issue_model_stats( + contact_center_insights.CalculateIssueModelStatsRequest(), + issue_model='issue_model_value', + ) + +@pytest.mark.asyncio +async def test_calculate_issue_model_stats_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_issue_model_stats), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.CalculateIssueModelStatsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.CalculateIssueModelStatsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.calculate_issue_model_stats( + issue_model='issue_model_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].issue_model + mock_val = 'issue_model_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_calculate_issue_model_stats_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.calculate_issue_model_stats( + contact_center_insights.CalculateIssueModelStatsRequest(), + issue_model='issue_model_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.CreatePhraseMatcherRequest, + dict, +]) +def test_create_phrase_matcher(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.PhraseMatcher( + name='name_value', + revision_id='revision_id_value', + version_tag='version_tag_value', + display_name='display_name_value', + type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, + active=True, + role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + ) + response = client.create_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreatePhraseMatcherRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.PhraseMatcher) + assert response.name == 'name_value' + assert response.revision_id == 'revision_id_value' + assert response.version_tag == 'version_tag_value' + assert response.display_name == 'display_name_value' + assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF + assert response.active is True + assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT + + +def test_create_phrase_matcher_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_phrase_matcher), + '__call__') as call: + client.create_phrase_matcher() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreatePhraseMatcherRequest() + +@pytest.mark.asyncio +async def test_create_phrase_matcher_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.CreatePhraseMatcherRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher( + name='name_value', + revision_id='revision_id_value', + version_tag='version_tag_value', + display_name='display_name_value', + type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, + active=True, + role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + )) + response = await client.create_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreatePhraseMatcherRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.PhraseMatcher) + assert response.name == 'name_value' + assert response.revision_id == 'revision_id_value' + assert response.version_tag == 'version_tag_value' + assert response.display_name == 'display_name_value' + assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF + assert response.active is True + assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT + + +@pytest.mark.asyncio +async def test_create_phrase_matcher_async_from_dict(): + await test_create_phrase_matcher_async(request_type=dict) + + +def test_create_phrase_matcher_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreatePhraseMatcherRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_phrase_matcher), + '__call__') as call: + call.return_value = resources.PhraseMatcher() + client.create_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_create_phrase_matcher_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreatePhraseMatcherRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_phrase_matcher), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher()) + await client.create_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_create_phrase_matcher_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.PhraseMatcher() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_phrase_matcher( + parent='parent_value', + phrase_matcher=resources.PhraseMatcher(name='name_value'), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].phrase_matcher + mock_val = resources.PhraseMatcher(name='name_value') + assert arg == mock_val + + +def test_create_phrase_matcher_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_phrase_matcher( + contact_center_insights.CreatePhraseMatcherRequest(), + parent='parent_value', + phrase_matcher=resources.PhraseMatcher(name='name_value'), + ) + +@pytest.mark.asyncio +async def test_create_phrase_matcher_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.PhraseMatcher() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_phrase_matcher( + parent='parent_value', + phrase_matcher=resources.PhraseMatcher(name='name_value'), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].phrase_matcher + mock_val = resources.PhraseMatcher(name='name_value') + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_phrase_matcher_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_phrase_matcher( + contact_center_insights.CreatePhraseMatcherRequest(), + parent='parent_value', + phrase_matcher=resources.PhraseMatcher(name='name_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.GetPhraseMatcherRequest, + dict, +]) +def test_get_phrase_matcher(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.PhraseMatcher( + name='name_value', + revision_id='revision_id_value', + version_tag='version_tag_value', + display_name='display_name_value', + type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, + active=True, + role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + ) + response = client.get_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetPhraseMatcherRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.PhraseMatcher) + assert response.name == 'name_value' + assert response.revision_id == 'revision_id_value' + assert response.version_tag == 'version_tag_value' + assert response.display_name == 'display_name_value' + assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF + assert response.active is True + assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT + + +def test_get_phrase_matcher_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_phrase_matcher), + '__call__') as call: + client.get_phrase_matcher() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetPhraseMatcherRequest() + +@pytest.mark.asyncio +async def test_get_phrase_matcher_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.GetPhraseMatcherRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher( + name='name_value', + revision_id='revision_id_value', + version_tag='version_tag_value', + display_name='display_name_value', + type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, + active=True, + role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + )) + response = await client.get_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetPhraseMatcherRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.PhraseMatcher) + assert response.name == 'name_value' + assert response.revision_id == 'revision_id_value' + assert response.version_tag == 'version_tag_value' + assert response.display_name == 'display_name_value' + assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF + assert response.active is True + assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT + + +@pytest.mark.asyncio +async def test_get_phrase_matcher_async_from_dict(): + await test_get_phrase_matcher_async(request_type=dict) + + +def test_get_phrase_matcher_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetPhraseMatcherRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_phrase_matcher), + '__call__') as call: + call.return_value = resources.PhraseMatcher() + client.get_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_get_phrase_matcher_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetPhraseMatcherRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_phrase_matcher), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher()) + await client.get_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_get_phrase_matcher_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.PhraseMatcher() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_phrase_matcher( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_phrase_matcher_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_phrase_matcher( + contact_center_insights.GetPhraseMatcherRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_phrase_matcher_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.PhraseMatcher() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_phrase_matcher( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_get_phrase_matcher_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_phrase_matcher( + contact_center_insights.GetPhraseMatcherRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.ListPhraseMatchersRequest, + dict, +]) +def test_list_phrase_matchers(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListPhraseMatchersResponse( + next_page_token='next_page_token_value', + ) + response = client.list_phrase_matchers(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListPhraseMatchersRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPhraseMatchersPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_phrase_matchers_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), + '__call__') as call: + client.list_phrase_matchers() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListPhraseMatchersRequest() + +@pytest.mark.asyncio +async def test_list_phrase_matchers_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.ListPhraseMatchersRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListPhraseMatchersResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_phrase_matchers(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListPhraseMatchersRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPhraseMatchersAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_phrase_matchers_async_from_dict(): + await test_list_phrase_matchers_async(request_type=dict) + + +def test_list_phrase_matchers_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListPhraseMatchersRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), + '__call__') as call: + call.return_value = contact_center_insights.ListPhraseMatchersResponse() + client.list_phrase_matchers(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_list_phrase_matchers_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListPhraseMatchersRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListPhraseMatchersResponse()) + await client.list_phrase_matchers(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_list_phrase_matchers_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListPhraseMatchersResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_phrase_matchers( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_phrase_matchers_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_phrase_matchers( + contact_center_insights.ListPhraseMatchersRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_phrase_matchers_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListPhraseMatchersResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListPhraseMatchersResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_phrase_matchers( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_list_phrase_matchers_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_phrase_matchers( + contact_center_insights.ListPhraseMatchersRequest(), + parent='parent_value', + ) + + +def test_list_phrase_matchers_pager(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + resources.PhraseMatcher(), + resources.PhraseMatcher(), + ], + next_page_token='abc', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[], + next_page_token='def', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + resources.PhraseMatcher(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_phrase_matchers(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.PhraseMatcher) + for i in results) +def test_list_phrase_matchers_pages(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + resources.PhraseMatcher(), + resources.PhraseMatcher(), + ], + next_page_token='abc', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[], + next_page_token='def', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + resources.PhraseMatcher(), + ], + ), + RuntimeError, + ) + pages = list(client.list_phrase_matchers(request={}).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.asyncio +async def test_list_phrase_matchers_async_pager(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + resources.PhraseMatcher(), + resources.PhraseMatcher(), + ], + next_page_token='abc', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[], + next_page_token='def', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + resources.PhraseMatcher(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_phrase_matchers(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.PhraseMatcher) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_phrase_matchers_async_pages(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_phrase_matchers), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + resources.PhraseMatcher(), + resources.PhraseMatcher(), + ], + next_page_token='abc', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[], + next_page_token='def', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + resources.PhraseMatcher(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_phrase_matchers(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.DeletePhraseMatcherRequest, + dict, +]) +def test_delete_phrase_matcher(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeletePhraseMatcherRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_phrase_matcher_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_phrase_matcher), + '__call__') as call: + client.delete_phrase_matcher() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeletePhraseMatcherRequest() + +@pytest.mark.asyncio +async def test_delete_phrase_matcher_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.DeletePhraseMatcherRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeletePhraseMatcherRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_phrase_matcher_async_from_dict(): + await test_delete_phrase_matcher_async(request_type=dict) + + +def test_delete_phrase_matcher_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeletePhraseMatcherRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_phrase_matcher), + '__call__') as call: + call.return_value = None + client.delete_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_delete_phrase_matcher_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeletePhraseMatcherRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_phrase_matcher), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_delete_phrase_matcher_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_phrase_matcher( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_delete_phrase_matcher_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_phrase_matcher( + contact_center_insights.DeletePhraseMatcherRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_phrase_matcher_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_phrase_matcher( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_delete_phrase_matcher_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_phrase_matcher( + contact_center_insights.DeletePhraseMatcherRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UpdatePhraseMatcherRequest, + dict, +]) +def test_update_phrase_matcher(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.PhraseMatcher( + name='name_value', + revision_id='revision_id_value', + version_tag='version_tag_value', + display_name='display_name_value', + type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, + active=True, + role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + ) + response = client.update_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdatePhraseMatcherRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.PhraseMatcher) + assert response.name == 'name_value' + assert response.revision_id == 'revision_id_value' + assert response.version_tag == 'version_tag_value' + assert response.display_name == 'display_name_value' + assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF + assert response.active is True + assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT + + +def test_update_phrase_matcher_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_phrase_matcher), + '__call__') as call: + client.update_phrase_matcher() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdatePhraseMatcherRequest() + +@pytest.mark.asyncio +async def test_update_phrase_matcher_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UpdatePhraseMatcherRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher( + name='name_value', + revision_id='revision_id_value', + version_tag='version_tag_value', + display_name='display_name_value', + type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, + active=True, + role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + )) + response = await client.update_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdatePhraseMatcherRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.PhraseMatcher) + assert response.name == 'name_value' + assert response.revision_id == 'revision_id_value' + assert response.version_tag == 'version_tag_value' + assert response.display_name == 'display_name_value' + assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF + assert response.active is True + assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT + + +@pytest.mark.asyncio +async def test_update_phrase_matcher_async_from_dict(): + await test_update_phrase_matcher_async(request_type=dict) + + +def test_update_phrase_matcher_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdatePhraseMatcherRequest() + + request.phrase_matcher.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_phrase_matcher), + '__call__') as call: + call.return_value = resources.PhraseMatcher() + client.update_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'phrase_matcher.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_phrase_matcher_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdatePhraseMatcherRequest() + + request.phrase_matcher.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_phrase_matcher), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher()) + await client.update_phrase_matcher(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'phrase_matcher.name=name_value', + ) in kw['metadata'] + + +def test_update_phrase_matcher_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.PhraseMatcher() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_phrase_matcher( + phrase_matcher=resources.PhraseMatcher(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].phrase_matcher + mock_val = resources.PhraseMatcher(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_phrase_matcher_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_phrase_matcher( + contact_center_insights.UpdatePhraseMatcherRequest(), + phrase_matcher=resources.PhraseMatcher(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_phrase_matcher_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_phrase_matcher), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.PhraseMatcher() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_phrase_matcher( + phrase_matcher=resources.PhraseMatcher(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].phrase_matcher + mock_val = resources.PhraseMatcher(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + +@pytest.mark.asyncio +async def test_update_phrase_matcher_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_phrase_matcher( + contact_center_insights.UpdatePhraseMatcherRequest(), + phrase_matcher=resources.PhraseMatcher(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.CalculateStatsRequest, + dict, +]) +def test_calculate_stats(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_stats), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.CalculateStatsResponse( + average_turn_count=1931, + conversation_count=1955, + ) + response = client.calculate_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CalculateStatsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.CalculateStatsResponse) + assert response.average_turn_count == 1931 + assert response.conversation_count == 1955 + + +def test_calculate_stats_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_stats), + '__call__') as call: + client.calculate_stats() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CalculateStatsRequest() + +@pytest.mark.asyncio +async def test_calculate_stats_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.CalculateStatsRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_stats), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.CalculateStatsResponse( + average_turn_count=1931, + conversation_count=1955, + )) + response = await client.calculate_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CalculateStatsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.CalculateStatsResponse) + assert response.average_turn_count == 1931 + assert response.conversation_count == 1955 + + +@pytest.mark.asyncio +async def test_calculate_stats_async_from_dict(): + await test_calculate_stats_async(request_type=dict) + + +def test_calculate_stats_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CalculateStatsRequest() + + request.location = 'location_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_stats), + '__call__') as call: + call.return_value = contact_center_insights.CalculateStatsResponse() + client.calculate_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'location=location_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_calculate_stats_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CalculateStatsRequest() + + request.location = 'location_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_stats), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.CalculateStatsResponse()) + await client.calculate_stats(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'location=location_value', + ) in kw['metadata'] + + +def test_calculate_stats_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_stats), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.CalculateStatsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.calculate_stats( + location='location_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].location + mock_val = 'location_value' + assert arg == mock_val + + +def test_calculate_stats_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.calculate_stats( + contact_center_insights.CalculateStatsRequest(), + location='location_value', + ) + +@pytest.mark.asyncio +async def test_calculate_stats_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.calculate_stats), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.CalculateStatsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.CalculateStatsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.calculate_stats( + location='location_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].location + mock_val = 'location_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_calculate_stats_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.calculate_stats( + contact_center_insights.CalculateStatsRequest(), + location='location_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.GetSettingsRequest, + dict, +]) +def test_get_settings(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Settings( + name='name_value', + language_code='language_code_value', + ) + response = client.get_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetSettingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Settings) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + + +def test_get_settings_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_settings), + '__call__') as call: + client.get_settings() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetSettingsRequest() + +@pytest.mark.asyncio +async def test_get_settings_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.GetSettingsRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Settings( + name='name_value', + language_code='language_code_value', + )) + response = await client.get_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetSettingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Settings) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + + +@pytest.mark.asyncio +async def test_get_settings_async_from_dict(): + await test_get_settings_async(request_type=dict) + + +def test_get_settings_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetSettingsRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_settings), + '__call__') as call: + call.return_value = resources.Settings() + client.get_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_get_settings_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetSettingsRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_settings), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Settings()) + await client.get_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_get_settings_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Settings() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_settings( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_settings_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_settings( + contact_center_insights.GetSettingsRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_settings_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Settings() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Settings()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_settings( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_get_settings_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_settings( + contact_center_insights.GetSettingsRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UpdateSettingsRequest, + dict, +]) +def test_update_settings(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Settings( + name='name_value', + language_code='language_code_value', + ) + response = client.update_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateSettingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Settings) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + + +def test_update_settings_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_settings), + '__call__') as call: + client.update_settings() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateSettingsRequest() + +@pytest.mark.asyncio +async def test_update_settings_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UpdateSettingsRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Settings( + name='name_value', + language_code='language_code_value', + )) + response = await client.update_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateSettingsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Settings) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + + +@pytest.mark.asyncio +async def test_update_settings_async_from_dict(): + await test_update_settings_async(request_type=dict) + + +def test_update_settings_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateSettingsRequest() + + request.settings.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_settings), + '__call__') as call: + call.return_value = resources.Settings() + client.update_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'settings.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_settings_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateSettingsRequest() + + request.settings.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_settings), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Settings()) + await client.update_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'settings.name=name_value', + ) in kw['metadata'] + + +def test_update_settings_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Settings() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_settings( + settings=resources.Settings(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].settings + mock_val = resources.Settings(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_settings_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_settings( + contact_center_insights.UpdateSettingsRequest(), + settings=resources.Settings(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_settings_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_settings), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Settings() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Settings()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_settings( + settings=resources.Settings(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].settings + mock_val = resources.Settings(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + +@pytest.mark.asyncio +async def test_update_settings_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_settings( + contact_center_insights.UpdateSettingsRequest(), + settings=resources.Settings(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.CreateViewRequest, + dict, +]) +def test_create_view(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View( + name='name_value', + display_name='display_name_value', + value='value_value', + ) + response = client.create_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateViewRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.View) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.value == 'value_value' + + +def test_create_view_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_view), + '__call__') as call: + client.create_view() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateViewRequest() + +@pytest.mark.asyncio +async def test_create_view_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.CreateViewRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.View( + name='name_value', + display_name='display_name_value', + value='value_value', + )) + response = await client.create_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateViewRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.View) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.value == 'value_value' + + +@pytest.mark.asyncio +async def test_create_view_async_from_dict(): + await test_create_view_async(request_type=dict) + + +def test_create_view_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateViewRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_view), + '__call__') as call: + call.return_value = resources.View() + client.create_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_create_view_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateViewRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_view), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) + await client.create_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_create_view_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_view( + parent='parent_value', + view=resources.View(name='name_value'), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].view + mock_val = resources.View(name='name_value') + assert arg == mock_val + + +def test_create_view_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_view( + contact_center_insights.CreateViewRequest(), + parent='parent_value', + view=resources.View(name='name_value'), + ) + +@pytest.mark.asyncio +async def test_create_view_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_view( + parent='parent_value', + view=resources.View(name='name_value'), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].view + mock_val = resources.View(name='name_value') + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_view_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_view( + contact_center_insights.CreateViewRequest(), + parent='parent_value', + view=resources.View(name='name_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.GetViewRequest, + dict, +]) +def test_get_view(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View( + name='name_value', + display_name='display_name_value', + value='value_value', + ) + response = client.get_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetViewRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.View) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.value == 'value_value' + + +def test_get_view_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_view), + '__call__') as call: + client.get_view() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetViewRequest() + +@pytest.mark.asyncio +async def test_get_view_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.GetViewRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.View( + name='name_value', + display_name='display_name_value', + value='value_value', + )) + response = await client.get_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetViewRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.View) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.value == 'value_value' + + +@pytest.mark.asyncio +async def test_get_view_async_from_dict(): + await test_get_view_async(request_type=dict) + + +def test_get_view_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetViewRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_view), + '__call__') as call: + call.return_value = resources.View() + client.get_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_get_view_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetViewRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_view), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) + await client.get_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_get_view_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_view( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_view_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_view( + contact_center_insights.GetViewRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_view_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_view( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_get_view_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_view( + contact_center_insights.GetViewRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.ListViewsRequest, + dict, +]) +def test_list_views(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_views), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListViewsResponse( + next_page_token='next_page_token_value', + ) + response = client.list_views(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListViewsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListViewsPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_views_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_views), + '__call__') as call: + client.list_views() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListViewsRequest() + +@pytest.mark.asyncio +async def test_list_views_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.ListViewsRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_views), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListViewsResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_views(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListViewsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListViewsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_views_async_from_dict(): + await test_list_views_async(request_type=dict) + + +def test_list_views_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListViewsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_views), + '__call__') as call: + call.return_value = contact_center_insights.ListViewsResponse() + client.list_views(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_list_views_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListViewsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_views), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListViewsResponse()) + await client.list_views(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_list_views_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_views), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListViewsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_views( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_views_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_views( + contact_center_insights.ListViewsRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_views_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_views), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListViewsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListViewsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_views( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_list_views_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_views( + contact_center_insights.ListViewsRequest(), + parent='parent_value', + ) + + +def test_list_views_pager(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_views), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + resources.View(), + ], + next_page_token='abc', + ), + contact_center_insights.ListViewsResponse( + views=[], + next_page_token='def', + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_views(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.View) + for i in results) +def test_list_views_pages(transport_name: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_views), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + resources.View(), + ], + next_page_token='abc', + ), + contact_center_insights.ListViewsResponse( + views=[], + next_page_token='def', + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + ], + ), + RuntimeError, + ) + pages = list(client.list_views(request={}).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.asyncio +async def test_list_views_async_pager(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_views), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + resources.View(), + ], + next_page_token='abc', + ), + contact_center_insights.ListViewsResponse( + views=[], + next_page_token='def', + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_views(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, resources.View) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_views_async_pages(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_views), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + resources.View(), + ], + next_page_token='abc', + ), + contact_center_insights.ListViewsResponse( + views=[], + next_page_token='def', + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_views(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UpdateViewRequest, + dict, +]) +def test_update_view(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View( + name='name_value', + display_name='display_name_value', + value='value_value', + ) + response = client.update_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateViewRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.View) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.value == 'value_value' + + +def test_update_view_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_view), + '__call__') as call: + client.update_view() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateViewRequest() + +@pytest.mark.asyncio +async def test_update_view_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UpdateViewRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.View( + name='name_value', + display_name='display_name_value', + value='value_value', + )) + response = await client.update_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateViewRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.View) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.value == 'value_value' + + +@pytest.mark.asyncio +async def test_update_view_async_from_dict(): + await test_update_view_async(request_type=dict) + + +def test_update_view_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateViewRequest() + + request.view.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_view), + '__call__') as call: + call.return_value = resources.View() + client.update_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'view.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_view_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateViewRequest() + + request.view.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_view), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) + await client.update_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'view.name=name_value', + ) in kw['metadata'] + + +def test_update_view_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_view( + view=resources.View(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].view + mock_val = resources.View(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_view_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_view( + contact_center_insights.UpdateViewRequest(), + view=resources.View(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_view_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = resources.View() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_view( + view=resources.View(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].view + mock_val = resources.View(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + +@pytest.mark.asyncio +async def test_update_view_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_view( + contact_center_insights.UpdateViewRequest(), + view=resources.View(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.DeleteViewRequest, + dict, +]) +def test_delete_view(request_type, transport: str = 'grpc'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteViewRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_view_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_view), + '__call__') as call: + client.delete_view() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteViewRequest() + +@pytest.mark.asyncio +async def test_delete_view_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.DeleteViewRequest): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteViewRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_view_async_from_dict(): + await test_delete_view_async(request_type=dict) + + +def test_delete_view_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteViewRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_view), + '__call__') as call: + call.return_value = None + client.delete_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_delete_view_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteViewRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_view), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_view(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_delete_view_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_view( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_delete_view_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_view( + contact_center_insights.DeleteViewRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_view_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_view), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_view( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_delete_view_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_view( + contact_center_insights.DeleteViewRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.CreateConversationRequest, + dict, +]) +def test_create_conversation_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["conversation"] = {'call_metadata': {'customer_channel': 1706, 'agent_channel': 1351}, 'expire_time': {'seconds': 751, 'nanos': 543}, 'ttl': {'seconds': 751, 'nanos': 543}, 'name': 'name_value', 'data_source': {'gcs_source': {'audio_uri': 'audio_uri_value', 'transcript_uri': 'transcript_uri_value'}, 'dialogflow_source': {'dialogflow_conversation': 'dialogflow_conversation_value', 'audio_uri': 'audio_uri_value'}}, 'create_time': {}, 'update_time': {}, 'start_time': {}, 'language_code': 'language_code_value', 'agent_id': 'agent_id_value', 'labels': {}, 'transcript': {'transcript_segments': [{'message_time': {}, 'text': 'text_value', 'confidence': 0.1038, 'words': [{'start_offset': {}, 'end_offset': {}, 'word': 'word_value', 'confidence': 0.1038}], 'language_code': 'language_code_value', 'channel_tag': 1140, 'segment_participant': {'dialogflow_participant_name': 'dialogflow_participant_name_value', 'user_id': 'user_id_value', 'dialogflow_participant': 'dialogflow_participant_value', 'obfuscated_external_user_id': 'obfuscated_external_user_id_value', 'role': 1}, 'dialogflow_segment_metadata': {'smart_reply_allowlist_covered': True}, 'sentiment': {'magnitude': 0.9580000000000001, 'score': 0.54}}]}, 'medium': 1, 'duration': {}, 'turn_count': 1105, 'latest_analysis': {'name': 'name_value', 'request_time': {}, 'create_time': {}, 'analysis_result': {'call_analysis_metadata': {'annotations': [{'interruption_data': {}, 'sentiment_data': {}, 'silence_data': {}, 'hold_data': {}, 'entity_mention_data': {'entity_unique_id': 'entity_unique_id_value', 'type_': 1, 'sentiment': {}}, 'intent_match_data': {'intent_unique_id': 'intent_unique_id_value'}, 'phrase_match_data': {'phrase_matcher': 'phrase_matcher_value', 'display_name': 'display_name_value'}, 'issue_match_data': {'issue_assignment': {'issue': 'issue_value', 'score': 0.54, 'display_name': 'display_name_value'}}, 'channel_tag': 1140, 'annotation_start_boundary': {'word_index': 1075, 'transcript_index': 1729}, 'annotation_end_boundary': {}}], 'entities': {}, 'sentiments': [{'channel_tag': 1140, 'sentiment_data': {}}], 'intents': {}, 'phrase_matchers': {}, 'issue_model_result': {'issue_model': 'issue_model_value', 'issues': {}}}, 'end_time': {}}, 'annotator_selector': {'run_interruption_annotator': True, 'run_silence_annotator': True, 'run_phrase_matcher_annotator': True, 'phrase_matchers': ['phrase_matchers_value1', 'phrase_matchers_value2'], 'run_sentiment_annotator': True, 'run_entity_annotator': True, 'run_intent_annotator': True, 'run_issue_model_annotator': True, 'issue_models': ['issue_models_value1', 'issue_models_value2'], 'run_summarization_annotator': True, 'summarization_config': {'conversation_profile': 'conversation_profile_value', 'summarization_model': 1}}}, 'latest_summary': {'text': 'text_value', 'text_sections': {}, 'confidence': 0.1038, 'metadata': {}, 'answer_record': 'answer_record_value', 'conversation_model': 'conversation_model_value'}, 'runtime_annotations': [{'article_suggestion': {'title': 'title_value', 'uri': 'uri_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value', 'source': 'source_value'}, 'faq_answer': {'answer': 'answer_value', 'confidence_score': 0.1673, 'question': 'question_value', 'metadata': {}, 'query_record': 'query_record_value', 'source': 'source_value'}, 'smart_reply': {'reply': 'reply_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value'}, 'smart_compose_suggestion': {'suggestion': 'suggestion_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value'}, 'dialogflow_interaction': {'dialogflow_intent_id': 'dialogflow_intent_id_value', 'confidence': 0.1038}, 'conversation_summarization_suggestion': {}, 'annotation_id': 'annotation_id_value', 'create_time': {}, 'start_boundary': {}, 'end_boundary': {}, 'answer_feedback': {'correctness_level': 1, 'clicked': True, 'displayed': True}}], 'dialogflow_intents': {}, 'obfuscated_user_id': 'obfuscated_user_id_value'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.Conversation( + name='name_value', + language_code='language_code_value', + agent_id='agent_id_value', + medium=resources.Conversation.Medium.PHONE_CALL, + turn_count=1105, + obfuscated_user_id='obfuscated_user_id_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Conversation.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.create_conversation(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Conversation) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + assert response.agent_id == 'agent_id_value' + assert response.medium == resources.Conversation.Medium.PHONE_CALL + assert response.turn_count == 1105 + assert response.obfuscated_user_id == 'obfuscated_user_id_value' + + +def test_create_conversation_rest_required_fields(request_type=contact_center_insights.CreateConversationRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_conversation._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_conversation._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("conversation_id", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.Conversation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.Conversation.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.create_conversation(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_conversation_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_conversation._get_unset_required_fields({}) + assert set(unset_fields) == (set(("conversationId", )) & set(("parent", "conversation", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_conversation_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_create_conversation") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_create_conversation") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.CreateConversationRequest.pb(contact_center_insights.CreateConversationRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.Conversation.to_json(resources.Conversation()) + + request = contact_center_insights.CreateConversationRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Conversation() + + client.create_conversation(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_conversation_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.CreateConversationRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["conversation"] = {'call_metadata': {'customer_channel': 1706, 'agent_channel': 1351}, 'expire_time': {'seconds': 751, 'nanos': 543}, 'ttl': {'seconds': 751, 'nanos': 543}, 'name': 'name_value', 'data_source': {'gcs_source': {'audio_uri': 'audio_uri_value', 'transcript_uri': 'transcript_uri_value'}, 'dialogflow_source': {'dialogflow_conversation': 'dialogflow_conversation_value', 'audio_uri': 'audio_uri_value'}}, 'create_time': {}, 'update_time': {}, 'start_time': {}, 'language_code': 'language_code_value', 'agent_id': 'agent_id_value', 'labels': {}, 'transcript': {'transcript_segments': [{'message_time': {}, 'text': 'text_value', 'confidence': 0.1038, 'words': [{'start_offset': {}, 'end_offset': {}, 'word': 'word_value', 'confidence': 0.1038}], 'language_code': 'language_code_value', 'channel_tag': 1140, 'segment_participant': {'dialogflow_participant_name': 'dialogflow_participant_name_value', 'user_id': 'user_id_value', 'dialogflow_participant': 'dialogflow_participant_value', 'obfuscated_external_user_id': 'obfuscated_external_user_id_value', 'role': 1}, 'dialogflow_segment_metadata': {'smart_reply_allowlist_covered': True}, 'sentiment': {'magnitude': 0.9580000000000001, 'score': 0.54}}]}, 'medium': 1, 'duration': {}, 'turn_count': 1105, 'latest_analysis': {'name': 'name_value', 'request_time': {}, 'create_time': {}, 'analysis_result': {'call_analysis_metadata': {'annotations': [{'interruption_data': {}, 'sentiment_data': {}, 'silence_data': {}, 'hold_data': {}, 'entity_mention_data': {'entity_unique_id': 'entity_unique_id_value', 'type_': 1, 'sentiment': {}}, 'intent_match_data': {'intent_unique_id': 'intent_unique_id_value'}, 'phrase_match_data': {'phrase_matcher': 'phrase_matcher_value', 'display_name': 'display_name_value'}, 'issue_match_data': {'issue_assignment': {'issue': 'issue_value', 'score': 0.54, 'display_name': 'display_name_value'}}, 'channel_tag': 1140, 'annotation_start_boundary': {'word_index': 1075, 'transcript_index': 1729}, 'annotation_end_boundary': {}}], 'entities': {}, 'sentiments': [{'channel_tag': 1140, 'sentiment_data': {}}], 'intents': {}, 'phrase_matchers': {}, 'issue_model_result': {'issue_model': 'issue_model_value', 'issues': {}}}, 'end_time': {}}, 'annotator_selector': {'run_interruption_annotator': True, 'run_silence_annotator': True, 'run_phrase_matcher_annotator': True, 'phrase_matchers': ['phrase_matchers_value1', 'phrase_matchers_value2'], 'run_sentiment_annotator': True, 'run_entity_annotator': True, 'run_intent_annotator': True, 'run_issue_model_annotator': True, 'issue_models': ['issue_models_value1', 'issue_models_value2'], 'run_summarization_annotator': True, 'summarization_config': {'conversation_profile': 'conversation_profile_value', 'summarization_model': 1}}}, 'latest_summary': {'text': 'text_value', 'text_sections': {}, 'confidence': 0.1038, 'metadata': {}, 'answer_record': 'answer_record_value', 'conversation_model': 'conversation_model_value'}, 'runtime_annotations': [{'article_suggestion': {'title': 'title_value', 'uri': 'uri_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value', 'source': 'source_value'}, 'faq_answer': {'answer': 'answer_value', 'confidence_score': 0.1673, 'question': 'question_value', 'metadata': {}, 'query_record': 'query_record_value', 'source': 'source_value'}, 'smart_reply': {'reply': 'reply_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value'}, 'smart_compose_suggestion': {'suggestion': 'suggestion_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value'}, 'dialogflow_interaction': {'dialogflow_intent_id': 'dialogflow_intent_id_value', 'confidence': 0.1038}, 'conversation_summarization_suggestion': {}, 'annotation_id': 'annotation_id_value', 'create_time': {}, 'start_boundary': {}, 'end_boundary': {}, 'answer_feedback': {'correctness_level': 1, 'clicked': True, 'displayed': True}}], 'dialogflow_intents': {}, 'obfuscated_user_id': 'obfuscated_user_id_value'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.create_conversation(request) + + +def test_create_conversation_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.Conversation() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), + conversation_id='conversation_id_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Conversation.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.create_conversation(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/conversations" % client.transport._host, args[1]) + + +def test_create_conversation_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_conversation( + contact_center_insights.CreateConversationRequest(), + parent='parent_value', + conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), + conversation_id='conversation_id_value', + ) + + +def test_create_conversation_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UploadConversationRequest, + dict, +]) +def test_upload_conversation_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.upload_conversation(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_upload_conversation_rest_required_fields(request_type=contact_center_insights.UploadConversationRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).upload_conversation._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).upload_conversation._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.upload_conversation(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_upload_conversation_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.upload_conversation._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent", "conversation", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_upload_conversation_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_upload_conversation") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_upload_conversation") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.UploadConversationRequest.pb(contact_center_insights.UploadConversationRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = contact_center_insights.UploadConversationRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.upload_conversation(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_upload_conversation_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.UploadConversationRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.upload_conversation(request) + + +def test_upload_conversation_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UpdateConversationRequest, + dict, +]) +def test_update_conversation_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'conversation': {'name': 'projects/sample1/locations/sample2/conversations/sample3'}} + request_init["conversation"] = {'call_metadata': {'customer_channel': 1706, 'agent_channel': 1351}, 'expire_time': {'seconds': 751, 'nanos': 543}, 'ttl': {'seconds': 751, 'nanos': 543}, 'name': 'projects/sample1/locations/sample2/conversations/sample3', 'data_source': {'gcs_source': {'audio_uri': 'audio_uri_value', 'transcript_uri': 'transcript_uri_value'}, 'dialogflow_source': {'dialogflow_conversation': 'dialogflow_conversation_value', 'audio_uri': 'audio_uri_value'}}, 'create_time': {}, 'update_time': {}, 'start_time': {}, 'language_code': 'language_code_value', 'agent_id': 'agent_id_value', 'labels': {}, 'transcript': {'transcript_segments': [{'message_time': {}, 'text': 'text_value', 'confidence': 0.1038, 'words': [{'start_offset': {}, 'end_offset': {}, 'word': 'word_value', 'confidence': 0.1038}], 'language_code': 'language_code_value', 'channel_tag': 1140, 'segment_participant': {'dialogflow_participant_name': 'dialogflow_participant_name_value', 'user_id': 'user_id_value', 'dialogflow_participant': 'dialogflow_participant_value', 'obfuscated_external_user_id': 'obfuscated_external_user_id_value', 'role': 1}, 'dialogflow_segment_metadata': {'smart_reply_allowlist_covered': True}, 'sentiment': {'magnitude': 0.9580000000000001, 'score': 0.54}}]}, 'medium': 1, 'duration': {}, 'turn_count': 1105, 'latest_analysis': {'name': 'name_value', 'request_time': {}, 'create_time': {}, 'analysis_result': {'call_analysis_metadata': {'annotations': [{'interruption_data': {}, 'sentiment_data': {}, 'silence_data': {}, 'hold_data': {}, 'entity_mention_data': {'entity_unique_id': 'entity_unique_id_value', 'type_': 1, 'sentiment': {}}, 'intent_match_data': {'intent_unique_id': 'intent_unique_id_value'}, 'phrase_match_data': {'phrase_matcher': 'phrase_matcher_value', 'display_name': 'display_name_value'}, 'issue_match_data': {'issue_assignment': {'issue': 'issue_value', 'score': 0.54, 'display_name': 'display_name_value'}}, 'channel_tag': 1140, 'annotation_start_boundary': {'word_index': 1075, 'transcript_index': 1729}, 'annotation_end_boundary': {}}], 'entities': {}, 'sentiments': [{'channel_tag': 1140, 'sentiment_data': {}}], 'intents': {}, 'phrase_matchers': {}, 'issue_model_result': {'issue_model': 'issue_model_value', 'issues': {}}}, 'end_time': {}}, 'annotator_selector': {'run_interruption_annotator': True, 'run_silence_annotator': True, 'run_phrase_matcher_annotator': True, 'phrase_matchers': ['phrase_matchers_value1', 'phrase_matchers_value2'], 'run_sentiment_annotator': True, 'run_entity_annotator': True, 'run_intent_annotator': True, 'run_issue_model_annotator': True, 'issue_models': ['issue_models_value1', 'issue_models_value2'], 'run_summarization_annotator': True, 'summarization_config': {'conversation_profile': 'conversation_profile_value', 'summarization_model': 1}}}, 'latest_summary': {'text': 'text_value', 'text_sections': {}, 'confidence': 0.1038, 'metadata': {}, 'answer_record': 'answer_record_value', 'conversation_model': 'conversation_model_value'}, 'runtime_annotations': [{'article_suggestion': {'title': 'title_value', 'uri': 'uri_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value', 'source': 'source_value'}, 'faq_answer': {'answer': 'answer_value', 'confidence_score': 0.1673, 'question': 'question_value', 'metadata': {}, 'query_record': 'query_record_value', 'source': 'source_value'}, 'smart_reply': {'reply': 'reply_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value'}, 'smart_compose_suggestion': {'suggestion': 'suggestion_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value'}, 'dialogflow_interaction': {'dialogflow_intent_id': 'dialogflow_intent_id_value', 'confidence': 0.1038}, 'conversation_summarization_suggestion': {}, 'annotation_id': 'annotation_id_value', 'create_time': {}, 'start_boundary': {}, 'end_boundary': {}, 'answer_feedback': {'correctness_level': 1, 'clicked': True, 'displayed': True}}], 'dialogflow_intents': {}, 'obfuscated_user_id': 'obfuscated_user_id_value'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.Conversation( + name='name_value', + language_code='language_code_value', + agent_id='agent_id_value', + medium=resources.Conversation.Medium.PHONE_CALL, + turn_count=1105, + obfuscated_user_id='obfuscated_user_id_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Conversation.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.update_conversation(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Conversation) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + assert response.agent_id == 'agent_id_value' + assert response.medium == resources.Conversation.Medium.PHONE_CALL + assert response.turn_count == 1105 + assert response.obfuscated_user_id == 'obfuscated_user_id_value' + + +def test_update_conversation_rest_required_fields(request_type=contact_center_insights.UpdateConversationRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_conversation._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_conversation._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.Conversation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "patch", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.Conversation.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.update_conversation(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_conversation_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_conversation._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("conversation", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_conversation_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_update_conversation") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_update_conversation") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.UpdateConversationRequest.pb(contact_center_insights.UpdateConversationRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.Conversation.to_json(resources.Conversation()) + + request = contact_center_insights.UpdateConversationRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Conversation() + + client.update_conversation(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_conversation_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.UpdateConversationRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'conversation': {'name': 'projects/sample1/locations/sample2/conversations/sample3'}} + request_init["conversation"] = {'call_metadata': {'customer_channel': 1706, 'agent_channel': 1351}, 'expire_time': {'seconds': 751, 'nanos': 543}, 'ttl': {'seconds': 751, 'nanos': 543}, 'name': 'projects/sample1/locations/sample2/conversations/sample3', 'data_source': {'gcs_source': {'audio_uri': 'audio_uri_value', 'transcript_uri': 'transcript_uri_value'}, 'dialogflow_source': {'dialogflow_conversation': 'dialogflow_conversation_value', 'audio_uri': 'audio_uri_value'}}, 'create_time': {}, 'update_time': {}, 'start_time': {}, 'language_code': 'language_code_value', 'agent_id': 'agent_id_value', 'labels': {}, 'transcript': {'transcript_segments': [{'message_time': {}, 'text': 'text_value', 'confidence': 0.1038, 'words': [{'start_offset': {}, 'end_offset': {}, 'word': 'word_value', 'confidence': 0.1038}], 'language_code': 'language_code_value', 'channel_tag': 1140, 'segment_participant': {'dialogflow_participant_name': 'dialogflow_participant_name_value', 'user_id': 'user_id_value', 'dialogflow_participant': 'dialogflow_participant_value', 'obfuscated_external_user_id': 'obfuscated_external_user_id_value', 'role': 1}, 'dialogflow_segment_metadata': {'smart_reply_allowlist_covered': True}, 'sentiment': {'magnitude': 0.9580000000000001, 'score': 0.54}}]}, 'medium': 1, 'duration': {}, 'turn_count': 1105, 'latest_analysis': {'name': 'name_value', 'request_time': {}, 'create_time': {}, 'analysis_result': {'call_analysis_metadata': {'annotations': [{'interruption_data': {}, 'sentiment_data': {}, 'silence_data': {}, 'hold_data': {}, 'entity_mention_data': {'entity_unique_id': 'entity_unique_id_value', 'type_': 1, 'sentiment': {}}, 'intent_match_data': {'intent_unique_id': 'intent_unique_id_value'}, 'phrase_match_data': {'phrase_matcher': 'phrase_matcher_value', 'display_name': 'display_name_value'}, 'issue_match_data': {'issue_assignment': {'issue': 'issue_value', 'score': 0.54, 'display_name': 'display_name_value'}}, 'channel_tag': 1140, 'annotation_start_boundary': {'word_index': 1075, 'transcript_index': 1729}, 'annotation_end_boundary': {}}], 'entities': {}, 'sentiments': [{'channel_tag': 1140, 'sentiment_data': {}}], 'intents': {}, 'phrase_matchers': {}, 'issue_model_result': {'issue_model': 'issue_model_value', 'issues': {}}}, 'end_time': {}}, 'annotator_selector': {'run_interruption_annotator': True, 'run_silence_annotator': True, 'run_phrase_matcher_annotator': True, 'phrase_matchers': ['phrase_matchers_value1', 'phrase_matchers_value2'], 'run_sentiment_annotator': True, 'run_entity_annotator': True, 'run_intent_annotator': True, 'run_issue_model_annotator': True, 'issue_models': ['issue_models_value1', 'issue_models_value2'], 'run_summarization_annotator': True, 'summarization_config': {'conversation_profile': 'conversation_profile_value', 'summarization_model': 1}}}, 'latest_summary': {'text': 'text_value', 'text_sections': {}, 'confidence': 0.1038, 'metadata': {}, 'answer_record': 'answer_record_value', 'conversation_model': 'conversation_model_value'}, 'runtime_annotations': [{'article_suggestion': {'title': 'title_value', 'uri': 'uri_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value', 'source': 'source_value'}, 'faq_answer': {'answer': 'answer_value', 'confidence_score': 0.1673, 'question': 'question_value', 'metadata': {}, 'query_record': 'query_record_value', 'source': 'source_value'}, 'smart_reply': {'reply': 'reply_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value'}, 'smart_compose_suggestion': {'suggestion': 'suggestion_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value'}, 'dialogflow_interaction': {'dialogflow_intent_id': 'dialogflow_intent_id_value', 'confidence': 0.1038}, 'conversation_summarization_suggestion': {}, 'annotation_id': 'annotation_id_value', 'create_time': {}, 'start_boundary': {}, 'end_boundary': {}, 'answer_feedback': {'correctness_level': 1, 'clicked': True, 'displayed': True}}], 'dialogflow_intents': {}, 'obfuscated_user_id': 'obfuscated_user_id_value'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.update_conversation(request) + + +def test_update_conversation_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.Conversation() + + # get arguments that satisfy an http rule for this method + sample_request = {'conversation': {'name': 'projects/sample1/locations/sample2/conversations/sample3'}} + + # get truthy value for each flattened field + mock_args = dict( + conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Conversation.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.update_conversation(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{conversation.name=projects/*/locations/*/conversations/*}" % client.transport._host, args[1]) + + +def test_update_conversation_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_conversation( + contact_center_insights.UpdateConversationRequest(), + conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_update_conversation_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.GetConversationRequest, + dict, +]) +def test_get_conversation_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/conversations/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.Conversation( + name='name_value', + language_code='language_code_value', + agent_id='agent_id_value', + medium=resources.Conversation.Medium.PHONE_CALL, + turn_count=1105, + obfuscated_user_id='obfuscated_user_id_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Conversation.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.get_conversation(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Conversation) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + assert response.agent_id == 'agent_id_value' + assert response.medium == resources.Conversation.Medium.PHONE_CALL + assert response.turn_count == 1105 + assert response.obfuscated_user_id == 'obfuscated_user_id_value' + + +def test_get_conversation_rest_required_fields(request_type=contact_center_insights.GetConversationRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_conversation._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_conversation._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("view", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.Conversation() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.Conversation.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.get_conversation(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_conversation_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_conversation._get_unset_required_fields({}) + assert set(unset_fields) == (set(("view", )) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_conversation_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_get_conversation") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_get_conversation") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.GetConversationRequest.pb(contact_center_insights.GetConversationRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.Conversation.to_json(resources.Conversation()) + + request = contact_center_insights.GetConversationRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Conversation() + + client.get_conversation(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_conversation_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.GetConversationRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/conversations/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_conversation(request) + + +def test_get_conversation_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.Conversation() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/conversations/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Conversation.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.get_conversation(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/conversations/*}" % client.transport._host, args[1]) + + +def test_get_conversation_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_conversation( + contact_center_insights.GetConversationRequest(), + name='name_value', + ) + + +def test_get_conversation_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.ListConversationsRequest, + dict, +]) +def test_list_conversations_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListConversationsResponse( + next_page_token='next_page_token_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = contact_center_insights.ListConversationsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.list_conversations(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListConversationsPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_conversations_rest_required_fields(request_type=contact_center_insights.ListConversationsRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_conversations._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_conversations._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("filter", "page_size", "page_token", "view", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListConversationsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = contact_center_insights.ListConversationsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.list_conversations(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_conversations_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_conversations._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "pageSize", "pageToken", "view", )) & set(("parent", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_conversations_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_list_conversations") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_list_conversations") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.ListConversationsRequest.pb(contact_center_insights.ListConversationsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = contact_center_insights.ListConversationsResponse.to_json(contact_center_insights.ListConversationsResponse()) + + request = contact_center_insights.ListConversationsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = contact_center_insights.ListConversationsResponse() + + client.list_conversations(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_conversations_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.ListConversationsRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_conversations(request) + + +def test_list_conversations_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListConversationsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = contact_center_insights.ListConversationsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.list_conversations(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/conversations" % client.transport._host, args[1]) + + +def test_list_conversations_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_conversations( + contact_center_insights.ListConversationsRequest(), + parent='parent_value', + ) + + +def test_list_conversations_rest_pager(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + resources.Conversation(), + resources.Conversation(), + ], + next_page_token='abc', + ), + contact_center_insights.ListConversationsResponse( + conversations=[], + next_page_token='def', + ), + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListConversationsResponse( + conversations=[ + resources.Conversation(), + resources.Conversation(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(contact_center_insights.ListConversationsResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + pager = client.list_conversations(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.Conversation) + for i in results) + + pages = list(client.list_conversations(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.DeleteConversationRequest, + dict, +]) +def test_delete_conversation_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/conversations/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = None + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = '' + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.delete_conversation(request) + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_conversation_rest_required_fields(request_type=contact_center_insights.DeleteConversationRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_conversation._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_conversation._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("force", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "delete", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = '' + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.delete_conversation(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_conversation_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_conversation._get_unset_required_fields({}) + assert set(unset_fields) == (set(("force", )) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_conversation_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_delete_conversation") as pre: + pre.assert_not_called() + pb_message = contact_center_insights.DeleteConversationRequest.pb(contact_center_insights.DeleteConversationRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + + request = contact_center_insights.DeleteConversationRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + + client.delete_conversation(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + + +def test_delete_conversation_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.DeleteConversationRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/conversations/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_conversation(request) + + +def test_delete_conversation_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/conversations/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = '' + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.delete_conversation(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/conversations/*}" % client.transport._host, args[1]) + + +def test_delete_conversation_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_conversation( + contact_center_insights.DeleteConversationRequest(), + name='name_value', + ) + + +def test_delete_conversation_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.CreateAnalysisRequest, + dict, +]) +def test_create_analysis_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/conversations/sample3'} + request_init["analysis"] = {'name': 'name_value', 'request_time': {'seconds': 751, 'nanos': 543}, 'create_time': {}, 'analysis_result': {'call_analysis_metadata': {'annotations': [{'interruption_data': {}, 'sentiment_data': {'magnitude': 0.9580000000000001, 'score': 0.54}, 'silence_data': {}, 'hold_data': {}, 'entity_mention_data': {'entity_unique_id': 'entity_unique_id_value', 'type_': 1, 'sentiment': {}}, 'intent_match_data': {'intent_unique_id': 'intent_unique_id_value'}, 'phrase_match_data': {'phrase_matcher': 'phrase_matcher_value', 'display_name': 'display_name_value'}, 'issue_match_data': {'issue_assignment': {'issue': 'issue_value', 'score': 0.54, 'display_name': 'display_name_value'}}, 'channel_tag': 1140, 'annotation_start_boundary': {'word_index': 1075, 'transcript_index': 1729}, 'annotation_end_boundary': {}}], 'entities': {}, 'sentiments': [{'channel_tag': 1140, 'sentiment_data': {}}], 'intents': {}, 'phrase_matchers': {}, 'issue_model_result': {'issue_model': 'issue_model_value', 'issues': {}}}, 'end_time': {}}, 'annotator_selector': {'run_interruption_annotator': True, 'run_silence_annotator': True, 'run_phrase_matcher_annotator': True, 'phrase_matchers': ['phrase_matchers_value1', 'phrase_matchers_value2'], 'run_sentiment_annotator': True, 'run_entity_annotator': True, 'run_intent_annotator': True, 'run_issue_model_annotator': True, 'issue_models': ['issue_models_value1', 'issue_models_value2'], 'run_summarization_annotator': True, 'summarization_config': {'conversation_profile': 'conversation_profile_value', 'summarization_model': 1}}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.create_analysis(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_create_analysis_rest_required_fields(request_type=contact_center_insights.CreateAnalysisRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_analysis._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_analysis._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.create_analysis(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_analysis_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_analysis._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent", "analysis", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_analysis_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_create_analysis") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_create_analysis") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.CreateAnalysisRequest.pb(contact_center_insights.CreateAnalysisRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = contact_center_insights.CreateAnalysisRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.create_analysis(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_analysis_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.CreateAnalysisRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/conversations/sample3'} + request_init["analysis"] = {'name': 'name_value', 'request_time': {'seconds': 751, 'nanos': 543}, 'create_time': {}, 'analysis_result': {'call_analysis_metadata': {'annotations': [{'interruption_data': {}, 'sentiment_data': {'magnitude': 0.9580000000000001, 'score': 0.54}, 'silence_data': {}, 'hold_data': {}, 'entity_mention_data': {'entity_unique_id': 'entity_unique_id_value', 'type_': 1, 'sentiment': {}}, 'intent_match_data': {'intent_unique_id': 'intent_unique_id_value'}, 'phrase_match_data': {'phrase_matcher': 'phrase_matcher_value', 'display_name': 'display_name_value'}, 'issue_match_data': {'issue_assignment': {'issue': 'issue_value', 'score': 0.54, 'display_name': 'display_name_value'}}, 'channel_tag': 1140, 'annotation_start_boundary': {'word_index': 1075, 'transcript_index': 1729}, 'annotation_end_boundary': {}}], 'entities': {}, 'sentiments': [{'channel_tag': 1140, 'sentiment_data': {}}], 'intents': {}, 'phrase_matchers': {}, 'issue_model_result': {'issue_model': 'issue_model_value', 'issues': {}}}, 'end_time': {}}, 'annotator_selector': {'run_interruption_annotator': True, 'run_silence_annotator': True, 'run_phrase_matcher_annotator': True, 'phrase_matchers': ['phrase_matchers_value1', 'phrase_matchers_value2'], 'run_sentiment_annotator': True, 'run_entity_annotator': True, 'run_intent_annotator': True, 'run_issue_model_annotator': True, 'issue_models': ['issue_models_value1', 'issue_models_value2'], 'run_summarization_annotator': True, 'summarization_config': {'conversation_profile': 'conversation_profile_value', 'summarization_model': 1}}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.create_analysis(request) + + +def test_create_analysis_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2/conversations/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + analysis=resources.Analysis(name='name_value'), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.create_analysis(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*/conversations/*}/analyses" % client.transport._host, args[1]) + + +def test_create_analysis_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_analysis( + contact_center_insights.CreateAnalysisRequest(), + parent='parent_value', + analysis=resources.Analysis(name='name_value'), + ) + + +def test_create_analysis_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.GetAnalysisRequest, + dict, +]) +def test_get_analysis_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/conversations/sample3/analyses/sample4'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.Analysis( + name='name_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Analysis.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.get_analysis(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Analysis) + assert response.name == 'name_value' + + +def test_get_analysis_rest_required_fields(request_type=contact_center_insights.GetAnalysisRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_analysis._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_analysis._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.Analysis() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.Analysis.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.get_analysis(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_analysis_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_analysis._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_analysis_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_get_analysis") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_get_analysis") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.GetAnalysisRequest.pb(contact_center_insights.GetAnalysisRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.Analysis.to_json(resources.Analysis()) + + request = contact_center_insights.GetAnalysisRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Analysis() + + client.get_analysis(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_analysis_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.GetAnalysisRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/conversations/sample3/analyses/sample4'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_analysis(request) + + +def test_get_analysis_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.Analysis() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/conversations/sample3/analyses/sample4'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Analysis.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.get_analysis(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/conversations/*/analyses/*}" % client.transport._host, args[1]) + + +def test_get_analysis_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_analysis( + contact_center_insights.GetAnalysisRequest(), + name='name_value', + ) + + +def test_get_analysis_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.ListAnalysesRequest, + dict, +]) +def test_list_analyses_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/conversations/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListAnalysesResponse( + next_page_token='next_page_token_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = contact_center_insights.ListAnalysesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.list_analyses(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListAnalysesPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_analyses_rest_required_fields(request_type=contact_center_insights.ListAnalysesRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_analyses._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_analyses._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("filter", "page_size", "page_token", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListAnalysesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = contact_center_insights.ListAnalysesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.list_analyses(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_analyses_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_analyses._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "pageSize", "pageToken", )) & set(("parent", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_analyses_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_list_analyses") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_list_analyses") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.ListAnalysesRequest.pb(contact_center_insights.ListAnalysesRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = contact_center_insights.ListAnalysesResponse.to_json(contact_center_insights.ListAnalysesResponse()) + + request = contact_center_insights.ListAnalysesRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = contact_center_insights.ListAnalysesResponse() + + client.list_analyses(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_analyses_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.ListAnalysesRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/conversations/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_analyses(request) + + +def test_list_analyses_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListAnalysesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2/conversations/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = contact_center_insights.ListAnalysesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.list_analyses(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*/conversations/*}/analyses" % client.transport._host, args[1]) + + +def test_list_analyses_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_analyses( + contact_center_insights.ListAnalysesRequest(), + parent='parent_value', + ) + + +def test_list_analyses_rest_pager(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + resources.Analysis(), + resources.Analysis(), + ], + next_page_token='abc', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[], + next_page_token='def', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListAnalysesResponse( + analyses=[ + resources.Analysis(), + resources.Analysis(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(contact_center_insights.ListAnalysesResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2/conversations/sample3'} + + pager = client.list_analyses(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.Analysis) + for i in results) + + pages = list(client.list_analyses(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.DeleteAnalysisRequest, + dict, +]) +def test_delete_analysis_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/conversations/sample3/analyses/sample4'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = None + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = '' + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.delete_analysis(request) + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_analysis_rest_required_fields(request_type=contact_center_insights.DeleteAnalysisRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_analysis._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_analysis._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "delete", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = '' + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.delete_analysis(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_analysis_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_analysis._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_analysis_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_delete_analysis") as pre: + pre.assert_not_called() + pb_message = contact_center_insights.DeleteAnalysisRequest.pb(contact_center_insights.DeleteAnalysisRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + + request = contact_center_insights.DeleteAnalysisRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + + client.delete_analysis(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + + +def test_delete_analysis_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.DeleteAnalysisRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/conversations/sample3/analyses/sample4'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_analysis(request) + + +def test_delete_analysis_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/conversations/sample3/analyses/sample4'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = '' + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.delete_analysis(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/conversations/*/analyses/*}" % client.transport._host, args[1]) + + +def test_delete_analysis_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_analysis( + contact_center_insights.DeleteAnalysisRequest(), + name='name_value', + ) + + +def test_delete_analysis_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.BulkAnalyzeConversationsRequest, + dict, +]) +def test_bulk_analyze_conversations_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.bulk_analyze_conversations(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_bulk_analyze_conversations_rest_required_fields(request_type=contact_center_insights.BulkAnalyzeConversationsRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["filter"] = "" + request_init["analysis_percentage"] = 0.0 + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).bulk_analyze_conversations._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + jsonified_request["filter"] = 'filter_value' + jsonified_request["analysisPercentage"] = 0.20170000000000002 + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).bulk_analyze_conversations._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + assert "filter" in jsonified_request + assert jsonified_request["filter"] == 'filter_value' + assert "analysisPercentage" in jsonified_request + assert jsonified_request["analysisPercentage"] == 0.20170000000000002 + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.bulk_analyze_conversations(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_bulk_analyze_conversations_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.bulk_analyze_conversations._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent", "filter", "analysisPercentage", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_bulk_analyze_conversations_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_bulk_analyze_conversations") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_bulk_analyze_conversations") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.BulkAnalyzeConversationsRequest.pb(contact_center_insights.BulkAnalyzeConversationsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = contact_center_insights.BulkAnalyzeConversationsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.bulk_analyze_conversations(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_bulk_analyze_conversations_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.BulkAnalyzeConversationsRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.bulk_analyze_conversations(request) + + +def test_bulk_analyze_conversations_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + filter='filter_value', + analysis_percentage=0.20170000000000002, + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.bulk_analyze_conversations(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/conversations:bulkAnalyze" % client.transport._host, args[1]) + + +def test_bulk_analyze_conversations_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.bulk_analyze_conversations( + contact_center_insights.BulkAnalyzeConversationsRequest(), + parent='parent_value', + filter='filter_value', + analysis_percentage=0.20170000000000002, + ) + + +def test_bulk_analyze_conversations_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.IngestConversationsRequest, + dict, +]) +def test_ingest_conversations_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.ingest_conversations(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_ingest_conversations_rest_required_fields(request_type=contact_center_insights.IngestConversationsRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).ingest_conversations._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).ingest_conversations._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.ingest_conversations(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_ingest_conversations_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.ingest_conversations._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_ingest_conversations_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_ingest_conversations") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_ingest_conversations") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.IngestConversationsRequest.pb(contact_center_insights.IngestConversationsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = contact_center_insights.IngestConversationsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.ingest_conversations(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_ingest_conversations_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.IngestConversationsRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.ingest_conversations(request) + + +def test_ingest_conversations_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.ingest_conversations(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/conversations:ingest" % client.transport._host, args[1]) + + +def test_ingest_conversations_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.ingest_conversations( + contact_center_insights.IngestConversationsRequest(), + parent='parent_value', + ) + + +def test_ingest_conversations_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.ExportInsightsDataRequest, + dict, +]) +def test_export_insights_data_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.export_insights_data(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_export_insights_data_rest_required_fields(request_type=contact_center_insights.ExportInsightsDataRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).export_insights_data._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).export_insights_data._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.export_insights_data(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_export_insights_data_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.export_insights_data._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_export_insights_data_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_export_insights_data") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_export_insights_data") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.ExportInsightsDataRequest.pb(contact_center_insights.ExportInsightsDataRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = contact_center_insights.ExportInsightsDataRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.export_insights_data(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_export_insights_data_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.ExportInsightsDataRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.export_insights_data(request) + + +def test_export_insights_data_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.export_insights_data(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/insightsdata:export" % client.transport._host, args[1]) + + +def test_export_insights_data_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.export_insights_data( + contact_center_insights.ExportInsightsDataRequest(), + parent='parent_value', + ) + + +def test_export_insights_data_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.CreateIssueModelRequest, + dict, +]) +def test_create_issue_model_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["issue_model"] = {'name': 'name_value', 'display_name': 'display_name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'issue_count': 1201, 'state': 1, 'input_data_config': {'medium': 1, 'training_conversations_count': 3025, 'filter': 'filter_value'}, 'training_stats': {'analyzed_conversations_count': 3021, 'unclassified_conversations_count': 3439, 'issue_stats': {}}, 'model_type': 1, 'language_code': 'language_code_value'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.create_issue_model(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_create_issue_model_rest_required_fields(request_type=contact_center_insights.CreateIssueModelRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.create_issue_model(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_issue_model_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_issue_model._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent", "issueModel", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_issue_model_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_create_issue_model") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_create_issue_model") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.CreateIssueModelRequest.pb(contact_center_insights.CreateIssueModelRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = contact_center_insights.CreateIssueModelRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.create_issue_model(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_issue_model_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.CreateIssueModelRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["issue_model"] = {'name': 'name_value', 'display_name': 'display_name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'issue_count': 1201, 'state': 1, 'input_data_config': {'medium': 1, 'training_conversations_count': 3025, 'filter': 'filter_value'}, 'training_stats': {'analyzed_conversations_count': 3021, 'unclassified_conversations_count': 3439, 'issue_stats': {}}, 'model_type': 1, 'language_code': 'language_code_value'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.create_issue_model(request) + + +def test_create_issue_model_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + issue_model=resources.IssueModel(name='name_value'), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.create_issue_model(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/issueModels" % client.transport._host, args[1]) + + +def test_create_issue_model_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_issue_model( + contact_center_insights.CreateIssueModelRequest(), + parent='parent_value', + issue_model=resources.IssueModel(name='name_value'), + ) + + +def test_create_issue_model_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UpdateIssueModelRequest, + dict, +]) +def test_update_issue_model_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'issue_model': {'name': 'projects/sample1/locations/sample2/issueModels/sample3'}} + request_init["issue_model"] = {'name': 'projects/sample1/locations/sample2/issueModels/sample3', 'display_name': 'display_name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'issue_count': 1201, 'state': 1, 'input_data_config': {'medium': 1, 'training_conversations_count': 3025, 'filter': 'filter_value'}, 'training_stats': {'analyzed_conversations_count': 3021, 'unclassified_conversations_count': 3439, 'issue_stats': {}}, 'model_type': 1, 'language_code': 'language_code_value'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.IssueModel( + name='name_value', + display_name='display_name_value', + issue_count=1201, + state=resources.IssueModel.State.UNDEPLOYED, + model_type=resources.IssueModel.ModelType.TYPE_V1, + language_code='language_code_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.IssueModel.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.update_issue_model(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.IssueModel) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.issue_count == 1201 + assert response.state == resources.IssueModel.State.UNDEPLOYED + assert response.model_type == resources.IssueModel.ModelType.TYPE_V1 + assert response.language_code == 'language_code_value' + + +def test_update_issue_model_rest_required_fields(request_type=contact_center_insights.UpdateIssueModelRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_issue_model._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.IssueModel() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "patch", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.IssueModel.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.update_issue_model(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_issue_model_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_issue_model._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("issueModel", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_issue_model_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_update_issue_model") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_update_issue_model") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.UpdateIssueModelRequest.pb(contact_center_insights.UpdateIssueModelRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.IssueModel.to_json(resources.IssueModel()) + + request = contact_center_insights.UpdateIssueModelRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.IssueModel() + + client.update_issue_model(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_issue_model_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.UpdateIssueModelRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'issue_model': {'name': 'projects/sample1/locations/sample2/issueModels/sample3'}} + request_init["issue_model"] = {'name': 'projects/sample1/locations/sample2/issueModels/sample3', 'display_name': 'display_name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'issue_count': 1201, 'state': 1, 'input_data_config': {'medium': 1, 'training_conversations_count': 3025, 'filter': 'filter_value'}, 'training_stats': {'analyzed_conversations_count': 3021, 'unclassified_conversations_count': 3439, 'issue_stats': {}}, 'model_type': 1, 'language_code': 'language_code_value'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.update_issue_model(request) + + +def test_update_issue_model_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.IssueModel() + + # get arguments that satisfy an http rule for this method + sample_request = {'issue_model': {'name': 'projects/sample1/locations/sample2/issueModels/sample3'}} + + # get truthy value for each flattened field + mock_args = dict( + issue_model=resources.IssueModel(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.IssueModel.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.update_issue_model(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{issue_model.name=projects/*/locations/*/issueModels/*}" % client.transport._host, args[1]) + + +def test_update_issue_model_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_issue_model( + contact_center_insights.UpdateIssueModelRequest(), + issue_model=resources.IssueModel(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_update_issue_model_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.GetIssueModelRequest, + dict, +]) +def test_get_issue_model_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.IssueModel( + name='name_value', + display_name='display_name_value', + issue_count=1201, + state=resources.IssueModel.State.UNDEPLOYED, + model_type=resources.IssueModel.ModelType.TYPE_V1, + language_code='language_code_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.IssueModel.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.get_issue_model(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.IssueModel) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.issue_count == 1201 + assert response.state == resources.IssueModel.State.UNDEPLOYED + assert response.model_type == resources.IssueModel.ModelType.TYPE_V1 + assert response.language_code == 'language_code_value' + + +def test_get_issue_model_rest_required_fields(request_type=contact_center_insights.GetIssueModelRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.IssueModel() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.IssueModel.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.get_issue_model(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_issue_model_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_issue_model._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_issue_model_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_get_issue_model") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_get_issue_model") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.GetIssueModelRequest.pb(contact_center_insights.GetIssueModelRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.IssueModel.to_json(resources.IssueModel()) + + request = contact_center_insights.GetIssueModelRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.IssueModel() + + client.get_issue_model(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_issue_model_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.GetIssueModelRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_issue_model(request) + + +def test_get_issue_model_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.IssueModel() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.IssueModel.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.get_issue_model(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/issueModels/*}" % client.transport._host, args[1]) + + +def test_get_issue_model_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_issue_model( + contact_center_insights.GetIssueModelRequest(), + name='name_value', + ) + + +def test_get_issue_model_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.ListIssueModelsRequest, + dict, +]) +def test_list_issue_models_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListIssueModelsResponse( + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = contact_center_insights.ListIssueModelsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.list_issue_models(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.ListIssueModelsResponse) + + +def test_list_issue_models_rest_required_fields(request_type=contact_center_insights.ListIssueModelsRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_issue_models._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_issue_models._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListIssueModelsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = contact_center_insights.ListIssueModelsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.list_issue_models(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_issue_models_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_issue_models._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_issue_models_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_list_issue_models") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_list_issue_models") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.ListIssueModelsRequest.pb(contact_center_insights.ListIssueModelsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = contact_center_insights.ListIssueModelsResponse.to_json(contact_center_insights.ListIssueModelsResponse()) + + request = contact_center_insights.ListIssueModelsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = contact_center_insights.ListIssueModelsResponse() + + client.list_issue_models(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_issue_models_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.ListIssueModelsRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_issue_models(request) + + +def test_list_issue_models_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListIssueModelsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = contact_center_insights.ListIssueModelsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.list_issue_models(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/issueModels" % client.transport._host, args[1]) + + +def test_list_issue_models_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_issue_models( + contact_center_insights.ListIssueModelsRequest(), + parent='parent_value', + ) + + +def test_list_issue_models_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.DeleteIssueModelRequest, + dict, +]) +def test_delete_issue_model_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.delete_issue_model(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_delete_issue_model_rest_required_fields(request_type=contact_center_insights.DeleteIssueModelRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "delete", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.delete_issue_model(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_issue_model_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_issue_model._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_issue_model_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_delete_issue_model") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_delete_issue_model") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.DeleteIssueModelRequest.pb(contact_center_insights.DeleteIssueModelRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = contact_center_insights.DeleteIssueModelRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.delete_issue_model(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_delete_issue_model_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.DeleteIssueModelRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_issue_model(request) + + +def test_delete_issue_model_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.delete_issue_model(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/issueModels/*}" % client.transport._host, args[1]) + + +def test_delete_issue_model_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_issue_model( + contact_center_insights.DeleteIssueModelRequest(), + name='name_value', + ) + + +def test_delete_issue_model_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.DeployIssueModelRequest, + dict, +]) +def test_deploy_issue_model_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.deploy_issue_model(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_deploy_issue_model_rest_required_fields(request_type=contact_center_insights.DeployIssueModelRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).deploy_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).deploy_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.deploy_issue_model(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_deploy_issue_model_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.deploy_issue_model._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_deploy_issue_model_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_deploy_issue_model") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_deploy_issue_model") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.DeployIssueModelRequest.pb(contact_center_insights.DeployIssueModelRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = contact_center_insights.DeployIssueModelRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.deploy_issue_model(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_deploy_issue_model_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.DeployIssueModelRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.deploy_issue_model(request) + + +def test_deploy_issue_model_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.deploy_issue_model(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/issueModels/*}:deploy" % client.transport._host, args[1]) + + +def test_deploy_issue_model_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.deploy_issue_model( + contact_center_insights.DeployIssueModelRequest(), + name='name_value', + ) + + +def test_deploy_issue_model_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UndeployIssueModelRequest, + dict, +]) +def test_undeploy_issue_model_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.undeploy_issue_model(request) + + # Establish that the response is the type that we expect. + assert response.operation.name == "operations/spam" + + +def test_undeploy_issue_model_rest_required_fields(request_type=contact_center_insights.UndeployIssueModelRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).undeploy_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).undeploy_issue_model._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.undeploy_issue_model(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_undeploy_issue_model_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.undeploy_issue_model._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_undeploy_issue_model_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_undeploy_issue_model") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_undeploy_issue_model") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.UndeployIssueModelRequest.pb(contact_center_insights.UndeployIssueModelRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) + + request = contact_center_insights.UndeployIssueModelRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.undeploy_issue_model(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_undeploy_issue_model_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.UndeployIssueModelRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.undeploy_issue_model(request) + + +def test_undeploy_issue_model_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.undeploy_issue_model(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/issueModels/*}:undeploy" % client.transport._host, args[1]) + + +def test_undeploy_issue_model_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.undeploy_issue_model( + contact_center_insights.UndeployIssueModelRequest(), + name='name_value', + ) + + +def test_undeploy_issue_model_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.GetIssueRequest, + dict, +]) +def test_get_issue_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.Issue( + name='name_value', + display_name='display_name_value', + sample_utterances=['sample_utterances_value'], + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Issue.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.get_issue(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Issue) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.sample_utterances == ['sample_utterances_value'] + + +def test_get_issue_rest_required_fields(request_type=contact_center_insights.GetIssueRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_issue._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_issue._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.Issue() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.Issue.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.get_issue(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_issue_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_issue._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_issue_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_get_issue") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_get_issue") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.GetIssueRequest.pb(contact_center_insights.GetIssueRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.Issue.to_json(resources.Issue()) + + request = contact_center_insights.GetIssueRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Issue() + + client.get_issue(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_issue_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.GetIssueRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_issue(request) + + +def test_get_issue_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.Issue() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Issue.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.get_issue(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/issueModels/*/issues/*}" % client.transport._host, args[1]) + + +def test_get_issue_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_issue( + contact_center_insights.GetIssueRequest(), + name='name_value', + ) + + +def test_get_issue_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.ListIssuesRequest, + dict, +]) +def test_list_issues_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/issueModels/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListIssuesResponse( + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = contact_center_insights.ListIssuesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.list_issues(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.ListIssuesResponse) + + +def test_list_issues_rest_required_fields(request_type=contact_center_insights.ListIssuesRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_issues._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_issues._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListIssuesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = contact_center_insights.ListIssuesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.list_issues(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_issues_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_issues._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_issues_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_list_issues") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_list_issues") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.ListIssuesRequest.pb(contact_center_insights.ListIssuesRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = contact_center_insights.ListIssuesResponse.to_json(contact_center_insights.ListIssuesResponse()) + + request = contact_center_insights.ListIssuesRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = contact_center_insights.ListIssuesResponse() + + client.list_issues(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_issues_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.ListIssuesRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/issueModels/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_issues(request) + + +def test_list_issues_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListIssuesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2/issueModels/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = contact_center_insights.ListIssuesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.list_issues(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*/issueModels/*}/issues" % client.transport._host, args[1]) + + +def test_list_issues_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_issues( + contact_center_insights.ListIssuesRequest(), + parent='parent_value', + ) + + +def test_list_issues_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UpdateIssueRequest, + dict, +]) +def test_update_issue_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'issue': {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4'}} + request_init["issue"] = {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4', 'display_name': 'display_name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'sample_utterances': ['sample_utterances_value1', 'sample_utterances_value2']} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.Issue( + name='name_value', + display_name='display_name_value', + sample_utterances=['sample_utterances_value'], + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Issue.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.update_issue(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Issue) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.sample_utterances == ['sample_utterances_value'] + + +def test_update_issue_rest_required_fields(request_type=contact_center_insights.UpdateIssueRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_issue._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_issue._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.Issue() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "patch", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.Issue.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.update_issue(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_issue_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_issue._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("issue", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_issue_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_update_issue") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_update_issue") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.UpdateIssueRequest.pb(contact_center_insights.UpdateIssueRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.Issue.to_json(resources.Issue()) + + request = contact_center_insights.UpdateIssueRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Issue() + + client.update_issue(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_issue_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.UpdateIssueRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'issue': {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4'}} + request_init["issue"] = {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4', 'display_name': 'display_name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'sample_utterances': ['sample_utterances_value1', 'sample_utterances_value2']} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.update_issue(request) + + +def test_update_issue_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.Issue() + + # get arguments that satisfy an http rule for this method + sample_request = {'issue': {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4'}} + + # get truthy value for each flattened field + mock_args = dict( + issue=resources.Issue(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Issue.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.update_issue(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{issue.name=projects/*/locations/*/issueModels/*/issues/*}" % client.transport._host, args[1]) + + +def test_update_issue_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_issue( + contact_center_insights.UpdateIssueRequest(), + issue=resources.Issue(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_update_issue_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.DeleteIssueRequest, + dict, +]) +def test_delete_issue_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = None + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = '' + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.delete_issue(request) + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_issue_rest_required_fields(request_type=contact_center_insights.DeleteIssueRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_issue._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_issue._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "delete", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = '' + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.delete_issue(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_issue_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_issue._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_issue_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_delete_issue") as pre: + pre.assert_not_called() + pb_message = contact_center_insights.DeleteIssueRequest.pb(contact_center_insights.DeleteIssueRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + + request = contact_center_insights.DeleteIssueRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + + client.delete_issue(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + + +def test_delete_issue_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.DeleteIssueRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_issue(request) + + +def test_delete_issue_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = '' + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.delete_issue(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/issueModels/*/issues/*}" % client.transport._host, args[1]) + + +def test_delete_issue_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_issue( + contact_center_insights.DeleteIssueRequest(), + name='name_value', + ) + + +def test_delete_issue_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.CalculateIssueModelStatsRequest, + dict, +]) +def test_calculate_issue_model_stats_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'issue_model': 'projects/sample1/locations/sample2/issueModels/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.CalculateIssueModelStatsResponse( + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = contact_center_insights.CalculateIssueModelStatsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.calculate_issue_model_stats(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.CalculateIssueModelStatsResponse) + + +def test_calculate_issue_model_stats_rest_required_fields(request_type=contact_center_insights.CalculateIssueModelStatsRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["issue_model"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).calculate_issue_model_stats._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["issueModel"] = 'issue_model_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).calculate_issue_model_stats._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "issueModel" in jsonified_request + assert jsonified_request["issueModel"] == 'issue_model_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.CalculateIssueModelStatsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = contact_center_insights.CalculateIssueModelStatsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.calculate_issue_model_stats(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_calculate_issue_model_stats_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.calculate_issue_model_stats._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("issueModel", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_calculate_issue_model_stats_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_calculate_issue_model_stats") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_calculate_issue_model_stats") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.CalculateIssueModelStatsRequest.pb(contact_center_insights.CalculateIssueModelStatsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = contact_center_insights.CalculateIssueModelStatsResponse.to_json(contact_center_insights.CalculateIssueModelStatsResponse()) + + request = contact_center_insights.CalculateIssueModelStatsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = contact_center_insights.CalculateIssueModelStatsResponse() + + client.calculate_issue_model_stats(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_calculate_issue_model_stats_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.CalculateIssueModelStatsRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'issue_model': 'projects/sample1/locations/sample2/issueModels/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.calculate_issue_model_stats(request) + + +def test_calculate_issue_model_stats_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.CalculateIssueModelStatsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'issue_model': 'projects/sample1/locations/sample2/issueModels/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + issue_model='issue_model_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = contact_center_insights.CalculateIssueModelStatsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.calculate_issue_model_stats(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{issue_model=projects/*/locations/*/issueModels/*}:calculateIssueModelStats" % client.transport._host, args[1]) + + +def test_calculate_issue_model_stats_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.calculate_issue_model_stats( + contact_center_insights.CalculateIssueModelStatsRequest(), + issue_model='issue_model_value', + ) + + +def test_calculate_issue_model_stats_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.CreatePhraseMatcherRequest, + dict, +]) +def test_create_phrase_matcher_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["phrase_matcher"] = {'name': 'name_value', 'revision_id': 'revision_id_value', 'version_tag': 'version_tag_value', 'revision_create_time': {'seconds': 751, 'nanos': 543}, 'display_name': 'display_name_value', 'type_': 1, 'active': True, 'phrase_match_rule_groups': [{'type_': 1, 'phrase_match_rules': [{'query': 'query_value', 'negated': True, 'config': {'exact_match_config': {'case_sensitive': True}}}]}], 'activation_update_time': {}, 'role_match': 1, 'update_time': {}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.PhraseMatcher( + name='name_value', + revision_id='revision_id_value', + version_tag='version_tag_value', + display_name='display_name_value', + type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, + active=True, + role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.PhraseMatcher.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.create_phrase_matcher(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.PhraseMatcher) + assert response.name == 'name_value' + assert response.revision_id == 'revision_id_value' + assert response.version_tag == 'version_tag_value' + assert response.display_name == 'display_name_value' + assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF + assert response.active is True + assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT + + +def test_create_phrase_matcher_rest_required_fields(request_type=contact_center_insights.CreatePhraseMatcherRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_phrase_matcher._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_phrase_matcher._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.PhraseMatcher() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.PhraseMatcher.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.create_phrase_matcher(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_phrase_matcher_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_phrase_matcher._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent", "phraseMatcher", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_phrase_matcher_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_create_phrase_matcher") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_create_phrase_matcher") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.CreatePhraseMatcherRequest.pb(contact_center_insights.CreatePhraseMatcherRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.PhraseMatcher.to_json(resources.PhraseMatcher()) + + request = contact_center_insights.CreatePhraseMatcherRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.PhraseMatcher() + + client.create_phrase_matcher(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_phrase_matcher_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.CreatePhraseMatcherRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["phrase_matcher"] = {'name': 'name_value', 'revision_id': 'revision_id_value', 'version_tag': 'version_tag_value', 'revision_create_time': {'seconds': 751, 'nanos': 543}, 'display_name': 'display_name_value', 'type_': 1, 'active': True, 'phrase_match_rule_groups': [{'type_': 1, 'phrase_match_rules': [{'query': 'query_value', 'negated': True, 'config': {'exact_match_config': {'case_sensitive': True}}}]}], 'activation_update_time': {}, 'role_match': 1, 'update_time': {}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.create_phrase_matcher(request) + + +def test_create_phrase_matcher_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.PhraseMatcher() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + phrase_matcher=resources.PhraseMatcher(name='name_value'), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.PhraseMatcher.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.create_phrase_matcher(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/phraseMatchers" % client.transport._host, args[1]) + + +def test_create_phrase_matcher_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_phrase_matcher( + contact_center_insights.CreatePhraseMatcherRequest(), + parent='parent_value', + phrase_matcher=resources.PhraseMatcher(name='name_value'), + ) + + +def test_create_phrase_matcher_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.GetPhraseMatcherRequest, + dict, +]) +def test_get_phrase_matcher_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.PhraseMatcher( + name='name_value', + revision_id='revision_id_value', + version_tag='version_tag_value', + display_name='display_name_value', + type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, + active=True, + role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.PhraseMatcher.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.get_phrase_matcher(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.PhraseMatcher) + assert response.name == 'name_value' + assert response.revision_id == 'revision_id_value' + assert response.version_tag == 'version_tag_value' + assert response.display_name == 'display_name_value' + assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF + assert response.active is True + assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT + + +def test_get_phrase_matcher_rest_required_fields(request_type=contact_center_insights.GetPhraseMatcherRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_phrase_matcher._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_phrase_matcher._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.PhraseMatcher() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.PhraseMatcher.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.get_phrase_matcher(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_phrase_matcher_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_phrase_matcher._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_phrase_matcher_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_get_phrase_matcher") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_get_phrase_matcher") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.GetPhraseMatcherRequest.pb(contact_center_insights.GetPhraseMatcherRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.PhraseMatcher.to_json(resources.PhraseMatcher()) + + request = contact_center_insights.GetPhraseMatcherRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.PhraseMatcher() + + client.get_phrase_matcher(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_phrase_matcher_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.GetPhraseMatcherRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_phrase_matcher(request) + + +def test_get_phrase_matcher_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.PhraseMatcher() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.PhraseMatcher.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.get_phrase_matcher(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/phraseMatchers/*}" % client.transport._host, args[1]) + + +def test_get_phrase_matcher_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_phrase_matcher( + contact_center_insights.GetPhraseMatcherRequest(), + name='name_value', + ) + + +def test_get_phrase_matcher_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.ListPhraseMatchersRequest, + dict, +]) +def test_list_phrase_matchers_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListPhraseMatchersResponse( + next_page_token='next_page_token_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = contact_center_insights.ListPhraseMatchersResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.list_phrase_matchers(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPhraseMatchersPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_phrase_matchers_rest_required_fields(request_type=contact_center_insights.ListPhraseMatchersRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_phrase_matchers._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_phrase_matchers._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("filter", "page_size", "page_token", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListPhraseMatchersResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = contact_center_insights.ListPhraseMatchersResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.list_phrase_matchers(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_phrase_matchers_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_phrase_matchers._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "pageSize", "pageToken", )) & set(("parent", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_phrase_matchers_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_list_phrase_matchers") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_list_phrase_matchers") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.ListPhraseMatchersRequest.pb(contact_center_insights.ListPhraseMatchersRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = contact_center_insights.ListPhraseMatchersResponse.to_json(contact_center_insights.ListPhraseMatchersResponse()) + + request = contact_center_insights.ListPhraseMatchersRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = contact_center_insights.ListPhraseMatchersResponse() + + client.list_phrase_matchers(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_phrase_matchers_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.ListPhraseMatchersRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_phrase_matchers(request) + + +def test_list_phrase_matchers_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListPhraseMatchersResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = contact_center_insights.ListPhraseMatchersResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.list_phrase_matchers(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/phraseMatchers" % client.transport._host, args[1]) + + +def test_list_phrase_matchers_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_phrase_matchers( + contact_center_insights.ListPhraseMatchersRequest(), + parent='parent_value', + ) + + +def test_list_phrase_matchers_rest_pager(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + resources.PhraseMatcher(), + resources.PhraseMatcher(), + ], + next_page_token='abc', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[], + next_page_token='def', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListPhraseMatchersResponse( + phrase_matchers=[ + resources.PhraseMatcher(), + resources.PhraseMatcher(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(contact_center_insights.ListPhraseMatchersResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + pager = client.list_phrase_matchers(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.PhraseMatcher) + for i in results) + + pages = list(client.list_phrase_matchers(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.DeletePhraseMatcherRequest, + dict, +]) +def test_delete_phrase_matcher_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = None + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = '' + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.delete_phrase_matcher(request) + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_phrase_matcher_rest_required_fields(request_type=contact_center_insights.DeletePhraseMatcherRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_phrase_matcher._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_phrase_matcher._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "delete", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = '' + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.delete_phrase_matcher(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_phrase_matcher_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_phrase_matcher._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_phrase_matcher_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_delete_phrase_matcher") as pre: + pre.assert_not_called() + pb_message = contact_center_insights.DeletePhraseMatcherRequest.pb(contact_center_insights.DeletePhraseMatcherRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + + request = contact_center_insights.DeletePhraseMatcherRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + + client.delete_phrase_matcher(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + + +def test_delete_phrase_matcher_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.DeletePhraseMatcherRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_phrase_matcher(request) + + +def test_delete_phrase_matcher_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = '' + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.delete_phrase_matcher(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/phraseMatchers/*}" % client.transport._host, args[1]) + + +def test_delete_phrase_matcher_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_phrase_matcher( + contact_center_insights.DeletePhraseMatcherRequest(), + name='name_value', + ) + + +def test_delete_phrase_matcher_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UpdatePhraseMatcherRequest, + dict, +]) +def test_update_phrase_matcher_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'phrase_matcher': {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3'}} + request_init["phrase_matcher"] = {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3', 'revision_id': 'revision_id_value', 'version_tag': 'version_tag_value', 'revision_create_time': {'seconds': 751, 'nanos': 543}, 'display_name': 'display_name_value', 'type_': 1, 'active': True, 'phrase_match_rule_groups': [{'type_': 1, 'phrase_match_rules': [{'query': 'query_value', 'negated': True, 'config': {'exact_match_config': {'case_sensitive': True}}}]}], 'activation_update_time': {}, 'role_match': 1, 'update_time': {}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.PhraseMatcher( + name='name_value', + revision_id='revision_id_value', + version_tag='version_tag_value', + display_name='display_name_value', + type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, + active=True, + role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.PhraseMatcher.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.update_phrase_matcher(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.PhraseMatcher) + assert response.name == 'name_value' + assert response.revision_id == 'revision_id_value' + assert response.version_tag == 'version_tag_value' + assert response.display_name == 'display_name_value' + assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF + assert response.active is True + assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT + + +def test_update_phrase_matcher_rest_required_fields(request_type=contact_center_insights.UpdatePhraseMatcherRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_phrase_matcher._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_phrase_matcher._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.PhraseMatcher() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "patch", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.PhraseMatcher.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.update_phrase_matcher(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_phrase_matcher_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_phrase_matcher._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("phraseMatcher", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_phrase_matcher_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_update_phrase_matcher") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_update_phrase_matcher") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.UpdatePhraseMatcherRequest.pb(contact_center_insights.UpdatePhraseMatcherRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.PhraseMatcher.to_json(resources.PhraseMatcher()) + + request = contact_center_insights.UpdatePhraseMatcherRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.PhraseMatcher() + + client.update_phrase_matcher(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_phrase_matcher_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.UpdatePhraseMatcherRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'phrase_matcher': {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3'}} + request_init["phrase_matcher"] = {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3', 'revision_id': 'revision_id_value', 'version_tag': 'version_tag_value', 'revision_create_time': {'seconds': 751, 'nanos': 543}, 'display_name': 'display_name_value', 'type_': 1, 'active': True, 'phrase_match_rule_groups': [{'type_': 1, 'phrase_match_rules': [{'query': 'query_value', 'negated': True, 'config': {'exact_match_config': {'case_sensitive': True}}}]}], 'activation_update_time': {}, 'role_match': 1, 'update_time': {}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.update_phrase_matcher(request) + + +def test_update_phrase_matcher_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.PhraseMatcher() + + # get arguments that satisfy an http rule for this method + sample_request = {'phrase_matcher': {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3'}} + + # get truthy value for each flattened field + mock_args = dict( + phrase_matcher=resources.PhraseMatcher(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.PhraseMatcher.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.update_phrase_matcher(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{phrase_matcher.name=projects/*/locations/*/phraseMatchers/*}" % client.transport._host, args[1]) + + +def test_update_phrase_matcher_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_phrase_matcher( + contact_center_insights.UpdatePhraseMatcherRequest(), + phrase_matcher=resources.PhraseMatcher(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_update_phrase_matcher_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.CalculateStatsRequest, + dict, +]) +def test_calculate_stats_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'location': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.CalculateStatsResponse( + average_turn_count=1931, + conversation_count=1955, + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = contact_center_insights.CalculateStatsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.calculate_stats(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.CalculateStatsResponse) + assert response.average_turn_count == 1931 + assert response.conversation_count == 1955 + + +def test_calculate_stats_rest_required_fields(request_type=contact_center_insights.CalculateStatsRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["location"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).calculate_stats._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["location"] = 'location_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).calculate_stats._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("filter", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "location" in jsonified_request + assert jsonified_request["location"] == 'location_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.CalculateStatsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = contact_center_insights.CalculateStatsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.calculate_stats(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_calculate_stats_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.calculate_stats._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", )) & set(("location", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_calculate_stats_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_calculate_stats") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_calculate_stats") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.CalculateStatsRequest.pb(contact_center_insights.CalculateStatsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = contact_center_insights.CalculateStatsResponse.to_json(contact_center_insights.CalculateStatsResponse()) + + request = contact_center_insights.CalculateStatsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = contact_center_insights.CalculateStatsResponse() + + client.calculate_stats(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_calculate_stats_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.CalculateStatsRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'location': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.calculate_stats(request) + + +def test_calculate_stats_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.CalculateStatsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'location': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + location='location_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = contact_center_insights.CalculateStatsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.calculate_stats(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{location=projects/*/locations/*}/conversations:calculateStats" % client.transport._host, args[1]) + + +def test_calculate_stats_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.calculate_stats( + contact_center_insights.CalculateStatsRequest(), + location='location_value', + ) + + +def test_calculate_stats_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.GetSettingsRequest, + dict, +]) +def test_get_settings_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/settings'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.Settings( + name='name_value', + language_code='language_code_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Settings.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.get_settings(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Settings) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + + +def test_get_settings_rest_required_fields(request_type=contact_center_insights.GetSettingsRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_settings._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_settings._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.Settings() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.Settings.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.get_settings(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_settings_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_settings._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_settings_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_get_settings") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_get_settings") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.GetSettingsRequest.pb(contact_center_insights.GetSettingsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.Settings.to_json(resources.Settings()) + + request = contact_center_insights.GetSettingsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Settings() + + client.get_settings(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_settings_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.GetSettingsRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/settings'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_settings(request) + + +def test_get_settings_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.Settings() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/settings'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Settings.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.get_settings(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/settings}" % client.transport._host, args[1]) + + +def test_get_settings_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_settings( + contact_center_insights.GetSettingsRequest(), + name='name_value', + ) + + +def test_get_settings_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UpdateSettingsRequest, + dict, +]) +def test_update_settings_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'settings': {'name': 'projects/sample1/locations/sample2/settings'}} + request_init["settings"] = {'name': 'projects/sample1/locations/sample2/settings', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'language_code': 'language_code_value', 'conversation_ttl': {'seconds': 751, 'nanos': 543}, 'pubsub_notification_settings': {}, 'analysis_config': {'runtime_integration_analysis_percentage': 0.4167, 'upload_conversation_analysis_percentage': 0.41590000000000005, 'annotator_selector': {'run_interruption_annotator': True, 'run_silence_annotator': True, 'run_phrase_matcher_annotator': True, 'phrase_matchers': ['phrase_matchers_value1', 'phrase_matchers_value2'], 'run_sentiment_annotator': True, 'run_entity_annotator': True, 'run_intent_annotator': True, 'run_issue_model_annotator': True, 'issue_models': ['issue_models_value1', 'issue_models_value2'], 'run_summarization_annotator': True, 'summarization_config': {'conversation_profile': 'conversation_profile_value', 'summarization_model': 1}}}, 'redaction_config': {'deidentify_template': 'deidentify_template_value', 'inspect_template': 'inspect_template_value'}, 'speech_config': {'speech_recognizer': 'speech_recognizer_value'}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.Settings( + name='name_value', + language_code='language_code_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Settings.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.update_settings(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Settings) + assert response.name == 'name_value' + assert response.language_code == 'language_code_value' + + +def test_update_settings_rest_required_fields(request_type=contact_center_insights.UpdateSettingsRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_settings._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_settings._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.Settings() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "patch", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.Settings.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.update_settings(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_settings_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_settings._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("settings", "updateMask", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_settings_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_update_settings") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_update_settings") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.UpdateSettingsRequest.pb(contact_center_insights.UpdateSettingsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.Settings.to_json(resources.Settings()) + + request = contact_center_insights.UpdateSettingsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.Settings() + + client.update_settings(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_settings_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.UpdateSettingsRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'settings': {'name': 'projects/sample1/locations/sample2/settings'}} + request_init["settings"] = {'name': 'projects/sample1/locations/sample2/settings', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'language_code': 'language_code_value', 'conversation_ttl': {'seconds': 751, 'nanos': 543}, 'pubsub_notification_settings': {}, 'analysis_config': {'runtime_integration_analysis_percentage': 0.4167, 'upload_conversation_analysis_percentage': 0.41590000000000005, 'annotator_selector': {'run_interruption_annotator': True, 'run_silence_annotator': True, 'run_phrase_matcher_annotator': True, 'phrase_matchers': ['phrase_matchers_value1', 'phrase_matchers_value2'], 'run_sentiment_annotator': True, 'run_entity_annotator': True, 'run_intent_annotator': True, 'run_issue_model_annotator': True, 'issue_models': ['issue_models_value1', 'issue_models_value2'], 'run_summarization_annotator': True, 'summarization_config': {'conversation_profile': 'conversation_profile_value', 'summarization_model': 1}}}, 'redaction_config': {'deidentify_template': 'deidentify_template_value', 'inspect_template': 'inspect_template_value'}, 'speech_config': {'speech_recognizer': 'speech_recognizer_value'}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.update_settings(request) + + +def test_update_settings_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.Settings() + + # get arguments that satisfy an http rule for this method + sample_request = {'settings': {'name': 'projects/sample1/locations/sample2/settings'}} + + # get truthy value for each flattened field + mock_args = dict( + settings=resources.Settings(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.Settings.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.update_settings(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{settings.name=projects/*/locations/*/settings}" % client.transport._host, args[1]) + + +def test_update_settings_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_settings( + contact_center_insights.UpdateSettingsRequest(), + settings=resources.Settings(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_update_settings_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.CreateViewRequest, + dict, +]) +def test_create_view_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["view"] = {'name': 'name_value', 'display_name': 'display_name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'value': 'value_value'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.View( + name='name_value', + display_name='display_name_value', + value='value_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.View.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.create_view(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.View) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.value == 'value_value' + + +def test_create_view_rest_required_fields(request_type=contact_center_insights.CreateViewRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_view._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_view._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.View() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.View.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.create_view(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_view_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_view._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent", "view", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_view_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_create_view") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_create_view") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.CreateViewRequest.pb(contact_center_insights.CreateViewRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.View.to_json(resources.View()) + + request = contact_center_insights.CreateViewRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.View() + + client.create_view(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_view_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.CreateViewRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["view"] = {'name': 'name_value', 'display_name': 'display_name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'value': 'value_value'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.create_view(request) + + +def test_create_view_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.View() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + view=resources.View(name='name_value'), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.View.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.create_view(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/views" % client.transport._host, args[1]) + + +def test_create_view_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_view( + contact_center_insights.CreateViewRequest(), + parent='parent_value', + view=resources.View(name='name_value'), + ) + + +def test_create_view_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.GetViewRequest, + dict, +]) +def test_get_view_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/views/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.View( + name='name_value', + display_name='display_name_value', + value='value_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.View.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.get_view(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.View) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.value == 'value_value' + + +def test_get_view_rest_required_fields(request_type=contact_center_insights.GetViewRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_view._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_view._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.View() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.View.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.get_view(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_view_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_view._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_view_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_get_view") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_get_view") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.GetViewRequest.pb(contact_center_insights.GetViewRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.View.to_json(resources.View()) + + request = contact_center_insights.GetViewRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.View() + + client.get_view(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_view_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.GetViewRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/views/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_view(request) + + +def test_get_view_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.View() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/views/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.View.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.get_view(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/views/*}" % client.transport._host, args[1]) + + +def test_get_view_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_view( + contact_center_insights.GetViewRequest(), + name='name_value', + ) + + +def test_get_view_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.ListViewsRequest, + dict, +]) +def test_list_views_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListViewsResponse( + next_page_token='next_page_token_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = contact_center_insights.ListViewsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.list_views(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListViewsPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_views_rest_required_fields(request_type=contact_center_insights.ListViewsRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_views._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_views._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("page_size", "page_token", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListViewsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = contact_center_insights.ListViewsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.list_views(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_views_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_views._get_unset_required_fields({}) + assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_views_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_list_views") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_list_views") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.ListViewsRequest.pb(contact_center_insights.ListViewsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = contact_center_insights.ListViewsResponse.to_json(contact_center_insights.ListViewsResponse()) + + request = contact_center_insights.ListViewsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = contact_center_insights.ListViewsResponse() + + client.list_views(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_views_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.ListViewsRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_views(request) + + +def test_list_views_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = contact_center_insights.ListViewsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = contact_center_insights.ListViewsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.list_views(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/views" % client.transport._host, args[1]) + + +def test_list_views_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_views( + contact_center_insights.ListViewsRequest(), + parent='parent_value', + ) + + +def test_list_views_rest_pager(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + resources.View(), + ], + next_page_token='abc', + ), + contact_center_insights.ListViewsResponse( + views=[], + next_page_token='def', + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + ], + next_page_token='ghi', + ), + contact_center_insights.ListViewsResponse( + views=[ + resources.View(), + resources.View(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(contact_center_insights.ListViewsResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + pager = client.list_views(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, resources.View) + for i in results) + + pages = list(client.list_views(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.UpdateViewRequest, + dict, +]) +def test_update_view_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'view': {'name': 'projects/sample1/locations/sample2/views/sample3'}} + request_init["view"] = {'name': 'projects/sample1/locations/sample2/views/sample3', 'display_name': 'display_name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'value': 'value_value'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.View( + name='name_value', + display_name='display_name_value', + value='value_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.View.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.update_view(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.View) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.value == 'value_value' + + +def test_update_view_rest_required_fields(request_type=contact_center_insights.UpdateViewRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_view._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_view._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = resources.View() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "patch", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = resources.View.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.update_view(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_view_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_view._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("view", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_view_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_update_view") as post, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_update_view") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = contact_center_insights.UpdateViewRequest.pb(contact_center_insights.UpdateViewRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = resources.View.to_json(resources.View()) + + request = contact_center_insights.UpdateViewRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = resources.View() + + client.update_view(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_view_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.UpdateViewRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'view': {'name': 'projects/sample1/locations/sample2/views/sample3'}} + request_init["view"] = {'name': 'projects/sample1/locations/sample2/views/sample3', 'display_name': 'display_name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'value': 'value_value'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.update_view(request) + + +def test_update_view_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = resources.View() + + # get arguments that satisfy an http rule for this method + sample_request = {'view': {'name': 'projects/sample1/locations/sample2/views/sample3'}} + + # get truthy value for each flattened field + mock_args = dict( + view=resources.View(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = resources.View.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.update_view(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{view.name=projects/*/locations/*/views/*}" % client.transport._host, args[1]) + + +def test_update_view_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_view( + contact_center_insights.UpdateViewRequest(), + view=resources.View(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_update_view_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + contact_center_insights.DeleteViewRequest, + dict, +]) +def test_delete_view_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/views/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = None + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = '' + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.delete_view(request) + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_view_rest_required_fields(request_type=contact_center_insights.DeleteViewRequest): + transport_class = transports.ContactCenterInsightsRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_view._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_view._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "delete", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = '' + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.delete_view(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_view_rest_unset_required_fields(): + transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_view._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_view_rest_interceptors(null_interceptor): + transport = transports.ContactCenterInsightsRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), + ) + client = ContactCenterInsightsClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_delete_view") as pre: + pre.assert_not_called() + pb_message = contact_center_insights.DeleteViewRequest.pb(contact_center_insights.DeleteViewRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + + request = contact_center_insights.DeleteViewRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + + client.delete_view(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + + +def test_delete_view_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.DeleteViewRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/views/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_view(request) + + +def test_delete_view_rest_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/views/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = '' + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.delete_view(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/views/*}" % client.transport._host, args[1]) + + +def test_delete_view_rest_flattened_error(transport: str = 'rest'): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_view( + contact_center_insights.DeleteViewRequest(), + name='name_value', + ) + + +def test_delete_view_rest_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.ContactCenterInsightsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.ContactCenterInsightsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = ContactCenterInsightsClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.ContactCenterInsightsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = ContactCenterInsightsClient( + client_options=options, + transport=transport, + ) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = ContactCenterInsightsClient( + client_options=options, + credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.ContactCenterInsightsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = ContactCenterInsightsClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.ContactCenterInsightsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = ContactCenterInsightsClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.ContactCenterInsightsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.ContactCenterInsightsGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.ContactCenterInsightsGrpcTransport, + transports.ContactCenterInsightsGrpcAsyncIOTransport, + transports.ContactCenterInsightsRestTransport, +]) +def test_transport_adc(transport_class): + # Test default credentials are used if not provided. + with mock.patch.object(google.auth, 'default') as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + +@pytest.mark.parametrize("transport_name", [ + "grpc", + "rest", +]) +def test_transport_kind(transport_name): + transport = ContactCenterInsightsClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + +def test_transport_grpc_default(): + # A client should use the gRPC transport by default. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.ContactCenterInsightsGrpcTransport, + ) + +def test_contact_center_insights_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.ContactCenterInsightsTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_contact_center_insights_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.contact_center_insights_v1.services.contact_center_insights.transports.ContactCenterInsightsTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.ContactCenterInsightsTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'create_conversation', + 'upload_conversation', + 'update_conversation', + 'get_conversation', + 'list_conversations', + 'delete_conversation', + 'create_analysis', + 'get_analysis', + 'list_analyses', + 'delete_analysis', + 'bulk_analyze_conversations', + 'ingest_conversations', + 'export_insights_data', + 'create_issue_model', + 'update_issue_model', + 'get_issue_model', + 'list_issue_models', + 'delete_issue_model', + 'deploy_issue_model', + 'undeploy_issue_model', + 'get_issue', + 'list_issues', + 'update_issue', + 'delete_issue', + 'calculate_issue_model_stats', + 'create_phrase_matcher', + 'get_phrase_matcher', + 'list_phrase_matchers', + 'delete_phrase_matcher', + 'update_phrase_matcher', + 'calculate_stats', + 'get_settings', + 'update_settings', + 'create_view', + 'get_view', + 'list_views', + 'update_view', + 'delete_view', + 'get_operation', + 'cancel_operation', + 'list_operations', + ) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + with pytest.raises(NotImplementedError): + transport.close() + + # Additionally, the LRO client (a property) should + # also raise NotImplementedError + with pytest.raises(NotImplementedError): + transport.operations_client + + # Catch all for all remaining methods and properties + remainder = [ + 'kind', + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + + +def test_contact_center_insights_base_transport_with_credentials_file(): + # Instantiate the base transport with a credentials file + with mock.patch.object(google.auth, 'load_credentials_from_file', autospec=True) as load_creds, mock.patch('google.cloud.contact_center_insights_v1.services.contact_center_insights.transports.ContactCenterInsightsTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.ContactCenterInsightsTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with("credentials.json", + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id="octopus", + ) + + +def test_contact_center_insights_base_transport_with_adc(): + # Test the default credentials are used if credentials and credentials_file are None. + with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.contact_center_insights_v1.services.contact_center_insights.transports.ContactCenterInsightsTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.ContactCenterInsightsTransport() + adc.assert_called_once() + + +def test_contact_center_insights_auth_adc(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + ContactCenterInsightsClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id=None, + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.ContactCenterInsightsGrpcTransport, + transports.ContactCenterInsightsGrpcAsyncIOTransport, + ], +) +def test_contact_center_insights_transport_auth_adc(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.ContactCenterInsightsGrpcTransport, + transports.ContactCenterInsightsGrpcAsyncIOTransport, + transports.ContactCenterInsightsRestTransport, + ], +) +def test_contact_center_insights_transport_auth_gdch_credentials(transport_class): + host = 'https://language.com' + api_audience_tests = [None, 'https://language2.com'] + api_audience_expect = [host, 'https://language2.com'] + for t, e in zip(api_audience_tests, api_audience_expect): + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + gdch_mock = mock.MagicMock() + type(gdch_mock).with_gdch_audience = mock.PropertyMock(return_value=gdch_mock) + adc.return_value = (gdch_mock, None) + transport_class(host=host, api_audience=t) + gdch_mock.with_gdch_audience.assert_called_once_with( + e + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.ContactCenterInsightsGrpcTransport, grpc_helpers), + (transports.ContactCenterInsightsGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_contact_center_insights_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class( + quota_project_id="octopus", + scopes=["1", "2"] + ) + + create_channel.assert_called_with( + "contactcenterinsights.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + scopes=["1", "2"], + default_host="contactcenterinsights.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize("transport_class", [transports.ContactCenterInsightsGrpcTransport, transports.ContactCenterInsightsGrpcAsyncIOTransport]) +def test_contact_center_insights_grpc_transport_client_cert_source_for_mtls( + transport_class +): + cred = ga_credentials.AnonymousCredentials() + + # Check ssl_channel_credentials is used if provided. + with mock.patch.object(transport_class, "create_channel") as mock_create_channel: + mock_ssl_channel_creds = mock.Mock() + transport_class( + host="squid.clam.whelk", + credentials=cred, + ssl_channel_credentials=mock_ssl_channel_creds + ) + mock_create_channel.assert_called_once_with( + "squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_channel_creds, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls + # is used. + with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): + with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: + transport_class( + credentials=cred, + client_cert_source_for_mtls=client_cert_source_callback + ) + expected_cert, expected_key = client_cert_source_callback() + mock_ssl_cred.assert_called_once_with( + certificate_chain=expected_cert, + private_key=expected_key + ) + +def test_contact_center_insights_http_transport_client_cert_source_for_mtls(): + cred = ga_credentials.AnonymousCredentials() + with mock.patch("google.auth.transport.requests.AuthorizedSession.configure_mtls_channel") as mock_configure_mtls_channel: + transports.ContactCenterInsightsRestTransport ( + credentials=cred, + client_cert_source_for_mtls=client_cert_source_callback + ) + mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback) + + +def test_contact_center_insights_rest_lro_client(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.AbstractOperationsClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +@pytest.mark.parametrize("transport_name", [ + "grpc", + "grpc_asyncio", + "rest", +]) +def test_contact_center_insights_host_no_port(transport_name): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='contactcenterinsights.googleapis.com'), + transport=transport_name, + ) + assert client.transport._host == ( + 'contactcenterinsights.googleapis.com:443' + if transport_name in ['grpc', 'grpc_asyncio'] + else 'https://contactcenterinsights.googleapis.com' + ) + +@pytest.mark.parametrize("transport_name", [ + "grpc", + "grpc_asyncio", + "rest", +]) +def test_contact_center_insights_host_with_port(transport_name): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='contactcenterinsights.googleapis.com:8000'), + transport=transport_name, + ) + assert client.transport._host == ( + 'contactcenterinsights.googleapis.com:8000' + if transport_name in ['grpc', 'grpc_asyncio'] + else 'https://contactcenterinsights.googleapis.com:8000' + ) + +@pytest.mark.parametrize("transport_name", [ + "rest", +]) +def test_contact_center_insights_client_transport_session_collision(transport_name): + creds1 = ga_credentials.AnonymousCredentials() + creds2 = ga_credentials.AnonymousCredentials() + client1 = ContactCenterInsightsClient( + credentials=creds1, + transport=transport_name, + ) + client2 = ContactCenterInsightsClient( + credentials=creds2, + transport=transport_name, + ) + session1 = client1.transport.create_conversation._session + session2 = client2.transport.create_conversation._session + assert session1 != session2 + session1 = client1.transport.upload_conversation._session + session2 = client2.transport.upload_conversation._session + assert session1 != session2 + session1 = client1.transport.update_conversation._session + session2 = client2.transport.update_conversation._session + assert session1 != session2 + session1 = client1.transport.get_conversation._session + session2 = client2.transport.get_conversation._session + assert session1 != session2 + session1 = client1.transport.list_conversations._session + session2 = client2.transport.list_conversations._session + assert session1 != session2 + session1 = client1.transport.delete_conversation._session + session2 = client2.transport.delete_conversation._session + assert session1 != session2 + session1 = client1.transport.create_analysis._session + session2 = client2.transport.create_analysis._session + assert session1 != session2 + session1 = client1.transport.get_analysis._session + session2 = client2.transport.get_analysis._session + assert session1 != session2 + session1 = client1.transport.list_analyses._session + session2 = client2.transport.list_analyses._session + assert session1 != session2 + session1 = client1.transport.delete_analysis._session + session2 = client2.transport.delete_analysis._session + assert session1 != session2 + session1 = client1.transport.bulk_analyze_conversations._session + session2 = client2.transport.bulk_analyze_conversations._session + assert session1 != session2 + session1 = client1.transport.ingest_conversations._session + session2 = client2.transport.ingest_conversations._session + assert session1 != session2 + session1 = client1.transport.export_insights_data._session + session2 = client2.transport.export_insights_data._session + assert session1 != session2 + session1 = client1.transport.create_issue_model._session + session2 = client2.transport.create_issue_model._session + assert session1 != session2 + session1 = client1.transport.update_issue_model._session + session2 = client2.transport.update_issue_model._session + assert session1 != session2 + session1 = client1.transport.get_issue_model._session + session2 = client2.transport.get_issue_model._session + assert session1 != session2 + session1 = client1.transport.list_issue_models._session + session2 = client2.transport.list_issue_models._session + assert session1 != session2 + session1 = client1.transport.delete_issue_model._session + session2 = client2.transport.delete_issue_model._session + assert session1 != session2 + session1 = client1.transport.deploy_issue_model._session + session2 = client2.transport.deploy_issue_model._session + assert session1 != session2 + session1 = client1.transport.undeploy_issue_model._session + session2 = client2.transport.undeploy_issue_model._session + assert session1 != session2 + session1 = client1.transport.get_issue._session + session2 = client2.transport.get_issue._session + assert session1 != session2 + session1 = client1.transport.list_issues._session + session2 = client2.transport.list_issues._session + assert session1 != session2 + session1 = client1.transport.update_issue._session + session2 = client2.transport.update_issue._session + assert session1 != session2 + session1 = client1.transport.delete_issue._session + session2 = client2.transport.delete_issue._session + assert session1 != session2 + session1 = client1.transport.calculate_issue_model_stats._session + session2 = client2.transport.calculate_issue_model_stats._session + assert session1 != session2 + session1 = client1.transport.create_phrase_matcher._session + session2 = client2.transport.create_phrase_matcher._session + assert session1 != session2 + session1 = client1.transport.get_phrase_matcher._session + session2 = client2.transport.get_phrase_matcher._session + assert session1 != session2 + session1 = client1.transport.list_phrase_matchers._session + session2 = client2.transport.list_phrase_matchers._session + assert session1 != session2 + session1 = client1.transport.delete_phrase_matcher._session + session2 = client2.transport.delete_phrase_matcher._session + assert session1 != session2 + session1 = client1.transport.update_phrase_matcher._session + session2 = client2.transport.update_phrase_matcher._session + assert session1 != session2 + session1 = client1.transport.calculate_stats._session + session2 = client2.transport.calculate_stats._session + assert session1 != session2 + session1 = client1.transport.get_settings._session + session2 = client2.transport.get_settings._session + assert session1 != session2 + session1 = client1.transport.update_settings._session + session2 = client2.transport.update_settings._session + assert session1 != session2 + session1 = client1.transport.create_view._session + session2 = client2.transport.create_view._session + assert session1 != session2 + session1 = client1.transport.get_view._session + session2 = client2.transport.get_view._session + assert session1 != session2 + session1 = client1.transport.list_views._session + session2 = client2.transport.list_views._session + assert session1 != session2 + session1 = client1.transport.update_view._session + session2 = client2.transport.update_view._session + assert session1 != session2 + session1 = client1.transport.delete_view._session + session2 = client2.transport.delete_view._session + assert session1 != session2 +def test_contact_center_insights_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.ContactCenterInsightsGrpcTransport( + host="squid.clam.whelk", + channel=channel, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None + + +def test_contact_center_insights_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.ContactCenterInsightsGrpcAsyncIOTransport( + host="squid.clam.whelk", + channel=channel, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize("transport_class", [transports.ContactCenterInsightsGrpcTransport, transports.ContactCenterInsightsGrpcAsyncIOTransport]) +def test_contact_center_insights_transport_channel_mtls_with_client_cert_source( + transport_class +): + with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_ssl_cred = mock.Mock() + grpc_ssl_channel_cred.return_value = mock_ssl_cred + + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + cred = ga_credentials.AnonymousCredentials() + with pytest.warns(DeprecationWarning): + with mock.patch.object(google.auth, 'default') as adc: + adc.return_value = (cred, None) + transport = transport_class( + host="squid.clam.whelk", + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=client_cert_source_callback, + ) + adc.assert_called_once() + + grpc_ssl_channel_cred.assert_called_once_with( + certificate_chain=b"cert bytes", private_key=b"key bytes" + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize("transport_class", [transports.ContactCenterInsightsGrpcTransport, transports.ContactCenterInsightsGrpcAsyncIOTransport]) +def test_contact_center_insights_transport_channel_mtls_with_adc( + transport_class +): + mock_ssl_cred = mock.Mock() + with mock.patch.multiple( + "google.auth.transport.grpc.SslCredentials", + __init__=mock.Mock(return_value=None), + ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), + ): + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + mock_cred = mock.Mock() + + with pytest.warns(DeprecationWarning): + transport = transport_class( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=None, + ) + + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + + +def test_contact_center_insights_grpc_lro_client(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.OperationsClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +def test_contact_center_insights_grpc_lro_async_client(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc_asyncio', + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.OperationsAsyncClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +def test_analysis_path(): + project = "squid" + location = "clam" + conversation = "whelk" + analysis = "octopus" + expected = "projects/{project}/locations/{location}/conversations/{conversation}/analyses/{analysis}".format(project=project, location=location, conversation=conversation, analysis=analysis, ) + actual = ContactCenterInsightsClient.analysis_path(project, location, conversation, analysis) + assert expected == actual + + +def test_parse_analysis_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + "conversation": "cuttlefish", + "analysis": "mussel", + } + path = ContactCenterInsightsClient.analysis_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_analysis_path(path) + assert expected == actual + +def test_conversation_path(): + project = "winkle" + location = "nautilus" + conversation = "scallop" + expected = "projects/{project}/locations/{location}/conversations/{conversation}".format(project=project, location=location, conversation=conversation, ) + actual = ContactCenterInsightsClient.conversation_path(project, location, conversation) + assert expected == actual + + +def test_parse_conversation_path(): + expected = { + "project": "abalone", + "location": "squid", + "conversation": "clam", + } + path = ContactCenterInsightsClient.conversation_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_conversation_path(path) + assert expected == actual + +def test_conversation_profile_path(): + project = "whelk" + location = "octopus" + conversation_profile = "oyster" + expected = "projects/{project}/locations/{location}/conversationProfiles/{conversation_profile}".format(project=project, location=location, conversation_profile=conversation_profile, ) + actual = ContactCenterInsightsClient.conversation_profile_path(project, location, conversation_profile) + assert expected == actual + + +def test_parse_conversation_profile_path(): + expected = { + "project": "nudibranch", + "location": "cuttlefish", + "conversation_profile": "mussel", + } + path = ContactCenterInsightsClient.conversation_profile_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_conversation_profile_path(path) + assert expected == actual + +def test_issue_path(): + project = "winkle" + location = "nautilus" + issue_model = "scallop" + issue = "abalone" + expected = "projects/{project}/locations/{location}/issueModels/{issue_model}/issues/{issue}".format(project=project, location=location, issue_model=issue_model, issue=issue, ) + actual = ContactCenterInsightsClient.issue_path(project, location, issue_model, issue) + assert expected == actual + + +def test_parse_issue_path(): + expected = { + "project": "squid", + "location": "clam", + "issue_model": "whelk", + "issue": "octopus", + } + path = ContactCenterInsightsClient.issue_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_issue_path(path) + assert expected == actual + +def test_issue_model_path(): + project = "oyster" + location = "nudibranch" + issue_model = "cuttlefish" + expected = "projects/{project}/locations/{location}/issueModels/{issue_model}".format(project=project, location=location, issue_model=issue_model, ) + actual = ContactCenterInsightsClient.issue_model_path(project, location, issue_model) + assert expected == actual + + +def test_parse_issue_model_path(): + expected = { + "project": "mussel", + "location": "winkle", + "issue_model": "nautilus", + } + path = ContactCenterInsightsClient.issue_model_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_issue_model_path(path) + assert expected == actual + +def test_participant_path(): + project = "scallop" + conversation = "abalone" + participant = "squid" + expected = "projects/{project}/conversations/{conversation}/participants/{participant}".format(project=project, conversation=conversation, participant=participant, ) + actual = ContactCenterInsightsClient.participant_path(project, conversation, participant) + assert expected == actual + + +def test_parse_participant_path(): + expected = { + "project": "clam", + "conversation": "whelk", + "participant": "octopus", + } + path = ContactCenterInsightsClient.participant_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_participant_path(path) + assert expected == actual + +def test_phrase_matcher_path(): + project = "oyster" + location = "nudibranch" + phrase_matcher = "cuttlefish" + expected = "projects/{project}/locations/{location}/phraseMatchers/{phrase_matcher}".format(project=project, location=location, phrase_matcher=phrase_matcher, ) + actual = ContactCenterInsightsClient.phrase_matcher_path(project, location, phrase_matcher) + assert expected == actual + + +def test_parse_phrase_matcher_path(): + expected = { + "project": "mussel", + "location": "winkle", + "phrase_matcher": "nautilus", + } + path = ContactCenterInsightsClient.phrase_matcher_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_phrase_matcher_path(path) + assert expected == actual + +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, ) + actual = ContactCenterInsightsClient.settings_path(project, location) + assert expected == actual + + +def test_parse_settings_path(): + expected = { + "project": "cuttlefish", + "location": "mussel", + } + path = ContactCenterInsightsClient.settings_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_settings_path(path) + assert expected == actual + +def test_view_path(): + project = "winkle" + location = "nautilus" + view = "scallop" + expected = "projects/{project}/locations/{location}/views/{view}".format(project=project, location=location, view=view, ) + actual = ContactCenterInsightsClient.view_path(project, location, view) + assert expected == actual + + +def test_parse_view_path(): + expected = { + "project": "abalone", + "location": "squid", + "view": "clam", + } + path = ContactCenterInsightsClient.view_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_view_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "whelk" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = ContactCenterInsightsClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "octopus", + } + path = ContactCenterInsightsClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "oyster" + expected = "folders/{folder}".format(folder=folder, ) + actual = ContactCenterInsightsClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "nudibranch", + } + path = ContactCenterInsightsClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "cuttlefish" + expected = "organizations/{organization}".format(organization=organization, ) + actual = ContactCenterInsightsClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "mussel", + } + path = ContactCenterInsightsClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "winkle" + expected = "projects/{project}".format(project=project, ) + actual = ContactCenterInsightsClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "nautilus", + } + path = ContactCenterInsightsClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_common_project_path(path) + assert expected == actual + +def test_common_location_path(): + project = "scallop" + location = "abalone" + expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + actual = ContactCenterInsightsClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "squid", + "location": "clam", + } + path = ContactCenterInsightsClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_common_location_path(path) + assert expected == actual + + +def test_client_with_default_client_info(): + client_info = gapic_v1.client_info.ClientInfo() + + with mock.patch.object(transports.ContactCenterInsightsTransport, '_prep_wrapped_messages') as prep: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.ContactCenterInsightsTransport, '_prep_wrapped_messages') as prep: + transport_class = ContactCenterInsightsClient.get_transport_class() + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", + ) + with mock.patch.object(type(getattr(client.transport, "grpc_channel")), "close") as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_cancel_operation_rest_bad_request(transport: str = 'rest', request_type=operations_pb2.CancelOperationRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + request = request_type() + request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2/operations/sample3'}, request) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.cancel_operation(request) + +@pytest.mark.parametrize("request_type", [ + operations_pb2.CancelOperationRequest, + dict, +]) +def test_cancel_operation_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request_init = {'name': 'projects/sample1/locations/sample2/operations/sample3'} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = None + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = '{}' + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.cancel_operation(request) + + # Establish that the response is the type that we expect. + assert response is None + +def test_get_operation_rest_bad_request(transport: str = 'rest', request_type=operations_pb2.GetOperationRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + request = request_type() + request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2/operations/sample3'}, request) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_operation(request) + +@pytest.mark.parametrize("request_type", [ + operations_pb2.GetOperationRequest, + dict, +]) +def test_get_operation_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request_init = {'name': 'projects/sample1/locations/sample2/operations/sample3'} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation() + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.get_operation(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + +def test_list_operations_rest_bad_request(transport: str = 'rest', request_type=operations_pb2.ListOperationsRequest): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + request = request_type() + request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2'}, request) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_operations(request) + +@pytest.mark.parametrize("request_type", [ + operations_pb2.ListOperationsRequest, + dict, +]) +def test_list_operations_rest(request_type): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request_init = {'name': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.ListOperationsResponse() + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.list_operations(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.ListOperationsResponse) + + +def test_cancel_operation(transport: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.CancelOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.cancel_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert response is None +@pytest.mark.asyncio +async def test_cancel_operation_async(transport: str = "grpc"): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.CancelOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + None + ) + response = await client.cancel_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert response is None + +def test_cancel_operation_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.CancelOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + call.return_value = None + + client.cancel_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=locations",) in kw["metadata"] +@pytest.mark.asyncio +async def test_cancel_operation_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.CancelOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + None + ) + await client.cancel_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=locations",) in kw["metadata"] + +def test_cancel_operation_from_dict(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + + response = client.cancel_operation( + request={ + "name": "locations", + } + ) + call.assert_called() +@pytest.mark.asyncio +async def test_cancel_operation_from_dict_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + None + ) + response = await client.cancel_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + +def test_get_operation(transport: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.GetOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation() + response = client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) +@pytest.mark.asyncio +async def test_get_operation_async(transport: str = "grpc"): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.GetOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + response = await client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + +def test_get_operation_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.GetOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + call.return_value = operations_pb2.Operation() + + client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=locations",) in kw["metadata"] +@pytest.mark.asyncio +async def test_get_operation_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.GetOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + await client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=locations",) in kw["metadata"] + +def test_get_operation_from_dict(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation() + + response = client.get_operation( + request={ + "name": "locations", + } + ) + call.assert_called() +@pytest.mark.asyncio +async def test_get_operation_from_dict_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + response = await client.get_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + +def test_list_operations(transport: str = "grpc"): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.ListOperationsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.ListOperationsResponse() + response = client.list_operations(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.ListOperationsResponse) +@pytest.mark.asyncio +async def test_list_operations_async(transport: str = "grpc"): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.ListOperationsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.ListOperationsResponse() + ) + response = await client.list_operations(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.ListOperationsResponse) + +def test_list_operations_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.ListOperationsRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + call.return_value = operations_pb2.ListOperationsResponse() + + client.list_operations(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=locations",) in kw["metadata"] +@pytest.mark.asyncio +async def test_list_operations_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.ListOperationsRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.ListOperationsResponse() + ) + await client.list_operations(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=locations",) in kw["metadata"] + +def test_list_operations_from_dict(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.ListOperationsResponse() + + response = client.list_operations( + request={ + "name": "locations", + } + ) + call.assert_called() +@pytest.mark.asyncio +async def test_list_operations_from_dict_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.ListOperationsResponse() + ) + response = await client.list_operations( + request={ + "name": "locations", + } + ) + call.assert_called() + + +def test_transport_close(): + transports = { + "rest": "_session", + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport + ) + with mock.patch.object(type(getattr(client.transport, close_name)), "close") as close: + with client: + close.assert_not_called() + close.assert_called_once() + +def test_client_ctx(): + transports = [ + 'rest', + 'grpc', + ] + for transport in transports: + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() + +@pytest.mark.parametrize("client_class,transport_class", [ + (ContactCenterInsightsClient, transports.ContactCenterInsightsGrpcTransport), + (ContactCenterInsightsAsyncClient, transports.ContactCenterInsightsGrpcAsyncIOTransport), +]) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) From f85838fe17d76962633038d8509247ef2bed17a9 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 25 Sep 2023 16:41:58 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .../v1/.coveragerc | 13 - .../v1/.flake8 | 33 - .../v1/MANIFEST.in | 2 - .../v1/README.rst | 49 - .../v1/docs/_static/custom.css | 3 - .../v1/docs/conf.py | 376 - .../contact_center_insights.rst | 10 - .../contact_center_insights_v1/services.rst | 6 - .../docs/contact_center_insights_v1/types.rst | 6 - .../v1/docs/index.rst | 7 - .../cloud/contact_center_insights/__init__.py | 237 - .../contact_center_insights/gapic_version.py | 16 - .../cloud/contact_center_insights/py.typed | 2 - .../contact_center_insights_v1/__init__.py | 238 - .../gapic_metadata.json | 598 - .../gapic_version.py | 16 - .../cloud/contact_center_insights_v1/py.typed | 2 - .../services/__init__.py | 15 - .../contact_center_insights/__init__.py | 22 - .../contact_center_insights/async_client.py | 4421 ---- .../contact_center_insights/client.py | 4707 ---- .../contact_center_insights/pagers.py | 503 - .../transports/__init__.py | 38 - .../transports/base.py | 702 - .../transports/grpc.py | 1311 - .../transports/grpc_asyncio.py | 1310 - .../transports/rest.py | 4718 ---- .../types/__init__.py | 232 - .../types/contact_center_insights.py | 1838 -- .../types/resources.py | 2539 -- .../v1/mypy.ini | 3 - .../v1/noxfile.py | 184 - ...sights_bulk_analyze_conversations_async.py | 58 - ...nsights_bulk_analyze_conversations_sync.py | 58 - ...ights_calculate_issue_model_stats_async.py | 52 - ...sights_calculate_issue_model_stats_sync.py | 52 - ...t_center_insights_calculate_stats_async.py | 52 - ...ct_center_insights_calculate_stats_sync.py | 52 - ...t_center_insights_create_analysis_async.py | 56 - ...ct_center_insights_create_analysis_sync.py | 56 - ...nter_insights_create_conversation_async.py | 52 - ...enter_insights_create_conversation_sync.py | 52 - ...enter_insights_create_issue_model_async.py | 56 - ...center_insights_create_issue_model_sync.py | 56 - ...er_insights_create_phrase_matcher_async.py | 56 - ...ter_insights_create_phrase_matcher_sync.py | 56 - ...ntact_center_insights_create_view_async.py | 52 - ...ontact_center_insights_create_view_sync.py | 52 - ...t_center_insights_delete_analysis_async.py | 50 - ...ct_center_insights_delete_analysis_sync.py | 50 - ...nter_insights_delete_conversation_async.py | 50 - ...enter_insights_delete_conversation_sync.py | 50 - ...tact_center_insights_delete_issue_async.py | 50 - ...enter_insights_delete_issue_model_async.py | 56 - ...center_insights_delete_issue_model_sync.py | 56 - ...ntact_center_insights_delete_issue_sync.py | 50 - ...er_insights_delete_phrase_matcher_async.py | 50 - ...ter_insights_delete_phrase_matcher_sync.py | 50 - ...ntact_center_insights_delete_view_async.py | 50 - ...ontact_center_insights_delete_view_sync.py | 50 - ...enter_insights_deploy_issue_model_async.py | 56 - ...center_insights_deploy_issue_model_sync.py | 56 - ...ter_insights_export_insights_data_async.py | 60 - ...nter_insights_export_insights_data_sync.py | 60 - ...tact_center_insights_get_analysis_async.py | 52 - ...ntact_center_insights_get_analysis_sync.py | 52 - ..._center_insights_get_conversation_async.py | 52 - ...t_center_insights_get_conversation_sync.py | 52 - ...contact_center_insights_get_issue_async.py | 52 - ...t_center_insights_get_issue_model_async.py | 52 - ...ct_center_insights_get_issue_model_sync.py | 52 - ..._contact_center_insights_get_issue_sync.py | 52 - ...enter_insights_get_phrase_matcher_async.py | 52 - ...center_insights_get_phrase_matcher_sync.py | 52 - ...tact_center_insights_get_settings_async.py | 52 - ...ntact_center_insights_get_settings_sync.py | 52 - ..._contact_center_insights_get_view_async.py | 52 - ...d_contact_center_insights_get_view_sync.py | 52 - ...ter_insights_ingest_conversations_async.py | 64 - ...nter_insights_ingest_conversations_sync.py | 64 - ...act_center_insights_list_analyses_async.py | 53 - ...tact_center_insights_list_analyses_sync.py | 53 - ...enter_insights_list_conversations_async.py | 53 - ...center_insights_list_conversations_sync.py | 53 - ...center_insights_list_issue_models_async.py | 52 - ..._center_insights_list_issue_models_sync.py | 52 - ...ntact_center_insights_list_issues_async.py | 52 - ...ontact_center_insights_list_issues_sync.py | 52 - ...ter_insights_list_phrase_matchers_async.py | 53 - ...nter_insights_list_phrase_matchers_sync.py | 53 - ...ontact_center_insights_list_views_async.py | 53 - ...contact_center_insights_list_views_sync.py | 53 - ...ter_insights_undeploy_issue_model_async.py | 56 - ...nter_insights_undeploy_issue_model_sync.py | 56 - ...nter_insights_update_conversation_async.py | 51 - ...enter_insights_update_conversation_sync.py | 51 - ...tact_center_insights_update_issue_async.py | 51 - ...enter_insights_update_issue_model_async.py | 51 - ...center_insights_update_issue_model_sync.py | 51 - ...ntact_center_insights_update_issue_sync.py | 51 - ...er_insights_update_phrase_matcher_async.py | 55 - ...ter_insights_update_phrase_matcher_sync.py | 55 - ...t_center_insights_update_settings_async.py | 51 - ...ct_center_insights_update_settings_sync.py | 51 - ...ntact_center_insights_update_view_async.py | 51 - ...ontact_center_insights_update_view_sync.py | 51 - ...nter_insights_upload_conversation_async.py | 56 - ...enter_insights_upload_conversation_sync.py | 56 - ...google.cloud.contactcenterinsights.v1.json | 6207 ----- ...xup_contact_center_insights_v1_keywords.py | 213 - .../v1/setup.py | 90 - .../v1/testing/constraints-3.10.txt | 6 - .../v1/testing/constraints-3.11.txt | 6 - .../v1/testing/constraints-3.12.txt | 6 - .../v1/testing/constraints-3.7.txt | 9 - .../v1/testing/constraints-3.8.txt | 6 - .../v1/testing/constraints-3.9.txt | 6 - .../v1/tests/__init__.py | 16 - .../v1/tests/unit/__init__.py | 16 - .../v1/tests/unit/gapic/__init__.py | 16 - .../contact_center_insights_v1/__init__.py | 16 - .../test_contact_center_insights.py | 21043 ---------------- .../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 +- 136 files changed, 130 insertions(+), 55907 deletions(-) delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/.coveragerc delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/.flake8 delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/MANIFEST.in delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/README.rst delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/docs/_static/custom.css delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/docs/conf.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/contact_center_insights.rst delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/services.rst delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/types.rst delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/docs/index.rst delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/__init__.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/gapic_version.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/py.typed delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/__init__.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/gapic_version.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/py.typed delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/__init__.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/__init__.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/pagers.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/__init__.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/rest.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/__init__.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/contact_center_insights.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/resources.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/mypy.ini delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/noxfile.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_conversation_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_conversation_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_view_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_view_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_view_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_view_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_conversation_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_conversation_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_settings_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_settings_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_view_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_view_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analyses_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analyses_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_conversations_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_conversations_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issues_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issues_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_views_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_views_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_conversation_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_conversation_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_settings_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_settings_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_view_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_view_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_async.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_sync.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/snippet_metadata_google.cloud.contactcenterinsights.v1.json delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/scripts/fixup_contact_center_insights_v1_keywords.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/setup.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.10.txt delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.11.txt delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.12.txt delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.7.txt delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.8.txt delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.9.txt delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/tests/__init__.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/__init__.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/__init__.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/contact_center_insights_v1/__init__.py delete mode 100644 owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/.coveragerc b/owl-bot-staging/google-cloud-contact-center-insights/v1/.coveragerc deleted file mode 100644 index 790480a7ffe3..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/.coveragerc +++ /dev/null @@ -1,13 +0,0 @@ -[run] -branch = True - -[report] -show_missing = True -omit = - google/cloud/contact_center_insights/__init__.py - google/cloud/contact_center_insights/gapic_version.py -exclude_lines = - # Re-enable the standard pragma - pragma: NO COVER - # Ignore debug-only repr - def __repr__ diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/.flake8 b/owl-bot-staging/google-cloud-contact-center-insights/v1/.flake8 deleted file mode 100644 index 29227d4cf419..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/.flake8 +++ /dev/null @@ -1,33 +0,0 @@ -# -*- 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 -# -# https://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. - -# Generated by synthtool. DO NOT EDIT! -[flake8] -ignore = E203, E266, E501, W503 -exclude = - # Exclude generated code. - **/proto/** - **/gapic/** - **/services/** - **/types/** - *_pb2.py - - # Standard linting exemptions. - **/.nox/** - __pycache__, - .git, - *.pyc, - conf.py diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/MANIFEST.in b/owl-bot-staging/google-cloud-contact-center-insights/v1/MANIFEST.in deleted file mode 100644 index 405104e9d5c6..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include google/cloud/contact_center_insights *.py -recursive-include google/cloud/contact_center_insights_v1 *.py diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/README.rst b/owl-bot-staging/google-cloud-contact-center-insights/v1/README.rst deleted file mode 100644 index d53e8514665f..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/README.rst +++ /dev/null @@ -1,49 +0,0 @@ -Python Client for Google Cloud Contact Center Insights API -================================================= - -Quick Start ------------ - -In order to use this library, you first need to go through the following steps: - -1. `Select or create a Cloud Platform project.`_ -2. `Enable billing for your project.`_ -3. Enable the Google Cloud Contact Center Insights API. -4. `Setup Authentication.`_ - -.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project -.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project -.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html - -Installation -~~~~~~~~~~~~ - -Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to -create isolated Python environments. The basic problem it addresses is one of -dependencies and versions, and indirectly permissions. - -With `virtualenv`_, it's possible to install this library without needing system -install permissions, and without clashing with the installed system -dependencies. - -.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ - - -Mac/Linux -^^^^^^^^^ - -.. code-block:: console - - python3 -m venv - source /bin/activate - /bin/pip install /path/to/library - - -Windows -^^^^^^^ - -.. code-block:: console - - python3 -m venv - \Scripts\activate - \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/_static/custom.css b/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/_static/custom.css deleted file mode 100644 index 06423be0b592..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/_static/custom.css +++ /dev/null @@ -1,3 +0,0 @@ -dl.field-list > dt { - min-width: 100px -} diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/conf.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/conf.py deleted file mode 100644 index a1dbf8f2d907..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/conf.py +++ /dev/null @@ -1,376 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# -# google-cloud-contact-center-insights documentation build configuration file -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys -import os -import shlex - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath("..")) - -__version__ = "0.1.0" - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = "4.0.1" - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.autosummary", - "sphinx.ext.intersphinx", - "sphinx.ext.coverage", - "sphinx.ext.napoleon", - "sphinx.ext.todo", - "sphinx.ext.viewcode", -] - -# autodoc/autosummary flags -autoclass_content = "both" -autodoc_default_flags = ["members"] -autosummary_generate = True - - -# Add any paths that contain templates here, relative to this directory. -templates_path = ["_templates"] - -# Allow markdown includes (so releases.md can include CHANGLEOG.md) -# http://www.sphinx-doc.org/en/master/markdown.html -source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -source_suffix = [".rst", ".md"] - -# The encoding of source files. -# source_encoding = 'utf-8-sig' - -# The root toctree document. -root_doc = "index" - -# General information about the project. -project = u"google-cloud-contact-center-insights" -copyright = u"2023, Google, LLC" -author = u"Google APIs" # TODO: autogenerate this bit - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The full version, including alpha/beta/rc tags. -release = __version__ -# The short X.Y version. -version = ".".join(release.split(".")[0:2]) - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = 'en' - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -# today = '' -# Else, today_fmt is used as the format for a strftime call. -# today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ["_build"] - -# The reST default role (used for this markup: `text`) to use for all -# documents. -# default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -# add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -# add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -# show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = "sphinx" - -# A list of ignored prefixes for module index sorting. -# modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -# keep_warnings = False - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = True - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = "alabaster" - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -html_theme_options = { - "description": "Google Cloud Client Libraries for Python", - "github_user": "googleapis", - "github_repo": "google-cloud-python", - "github_banner": True, - "font_family": "'Roboto', Georgia, sans", - "head_font_family": "'Roboto', Georgia, serif", - "code_font_family": "'Roboto Mono', 'Consolas', monospace", -} - -# Add any paths that contain custom themes here, relative to this directory. -# html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -# html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -# html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -# html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -# html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] - -# Add any extra paths that contain custom files (such as robots.txt or -# .htaccess) here, relative to this directory. These files are copied -# directly to the root of the documentation. -# html_extra_path = [] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -# html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -# html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -# html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -# html_additional_pages = {} - -# If false, no module index is generated. -# html_domain_indices = True - -# If false, no index is generated. -# html_use_index = True - -# If true, the index is split into individual pages for each letter. -# html_split_index = False - -# If true, links to the reST sources are added to the pages. -# html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -# html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -# html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -# html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -# html_file_suffix = None - -# Language to be used for generating the HTML full-text search index. -# Sphinx supports the following languages: -# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' -# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' -# html_search_language = 'en' - -# A dictionary with options for the search language support, empty by default. -# Now only 'ja' uses this config value -# html_search_options = {'type': 'default'} - -# The name of a javascript file (relative to the configuration directory) that -# implements a search results scorer. If empty, the default will be used. -# html_search_scorer = 'scorer.js' - -# Output file base name for HTML help builder. -htmlhelp_basename = "google-cloud-contact-center-insights-doc" - -# -- Options for warnings ------------------------------------------------------ - - -suppress_warnings = [ - # Temporarily suppress this to avoid "more than one target found for - # cross-reference" warning, which are intractable for us to avoid while in - # a mono-repo. - # See https://github.com/sphinx-doc/sphinx/blob - # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 - "ref.python" -] - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). - # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. - # 'preamble': '', - # Latex figure (float) alignment - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - ( - root_doc, - "google-cloud-contact-center-insights.tex", - u"google-cloud-contact-center-insights Documentation", - author, - "manual", - ) -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -# latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -# latex_use_parts = False - -# If true, show page references after internal links. -# latex_show_pagerefs = False - -# If true, show URL addresses after external links. -# latex_show_urls = False - -# Documents to append as an appendix to all manuals. -# latex_appendices = [] - -# If false, no module index is generated. -# latex_domain_indices = True - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ( - root_doc, - "google-cloud-contact-center-insights", - u"Google Cloud Contact Center Insights Documentation", - [author], - 1, - ) -] - -# If true, show URL addresses after external links. -# man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ( - root_doc, - "google-cloud-contact-center-insights", - u"google-cloud-contact-center-insights Documentation", - author, - "google-cloud-contact-center-insights", - "GAPIC library for Google Cloud Contact Center Insights API", - "APIs", - ) -] - -# Documents to append as an appendix to all manuals. -# texinfo_appendices = [] - -# If false, no module index is generated. -# texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -# texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -# texinfo_no_detailmenu = False - - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = { - "python": ("http://python.readthedocs.org/en/latest/", None), - "gax": ("https://gax-python.readthedocs.org/en/latest/", None), - "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), - "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), - "grpc": ("https://grpc.io/grpc/python/", None), - "requests": ("http://requests.kennethreitz.org/en/stable/", None), - "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), - "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), -} - - -# Napoleon settings -napoleon_google_docstring = True -napoleon_numpy_docstring = True -napoleon_include_private_with_doc = False -napoleon_include_special_with_doc = True -napoleon_use_admonition_for_examples = False -napoleon_use_admonition_for_notes = False -napoleon_use_admonition_for_references = False -napoleon_use_ivar = False -napoleon_use_param = True -napoleon_use_rtype = True diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/contact_center_insights.rst b/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/contact_center_insights.rst deleted file mode 100644 index bb343f0b0f34..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/contact_center_insights.rst +++ /dev/null @@ -1,10 +0,0 @@ -ContactCenterInsights ---------------------------------------- - -.. automodule:: google.cloud.contact_center_insights_v1.services.contact_center_insights - :members: - :inherited-members: - -.. automodule:: google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/services.rst b/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/services.rst deleted file mode 100644 index 0147aecd0488..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/services.rst +++ /dev/null @@ -1,6 +0,0 @@ -Services for Google Cloud Contact Center Insights v1 API -======================================================== -.. toctree:: - :maxdepth: 2 - - contact_center_insights diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/types.rst b/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/types.rst deleted file mode 100644 index 270019e6a6fe..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/contact_center_insights_v1/types.rst +++ /dev/null @@ -1,6 +0,0 @@ -Types for Google Cloud Contact Center Insights v1 API -===================================================== - -.. automodule:: google.cloud.contact_center_insights_v1.types - :members: - :show-inheritance: diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/index.rst b/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/index.rst deleted file mode 100644 index d91ad872f07d..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/docs/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -API Reference -------------- -.. toctree:: - :maxdepth: 2 - - contact_center_insights_v1/services - contact_center_insights_v1/types diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/__init__.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/__init__.py deleted file mode 100644 index 02503043743d..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/__init__.py +++ /dev/null @@ -1,237 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -from google.cloud.contact_center_insights import gapic_version as package_version - -__version__ = package_version.__version__ - - -from google.cloud.contact_center_insights_v1.services.contact_center_insights.client import ContactCenterInsightsClient -from google.cloud.contact_center_insights_v1.services.contact_center_insights.async_client import ContactCenterInsightsAsyncClient - -from google.cloud.contact_center_insights_v1.types.contact_center_insights import BulkAnalyzeConversationsMetadata -from google.cloud.contact_center_insights_v1.types.contact_center_insights import BulkAnalyzeConversationsRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import BulkAnalyzeConversationsResponse -from google.cloud.contact_center_insights_v1.types.contact_center_insights import CalculateIssueModelStatsRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import CalculateIssueModelStatsResponse -from google.cloud.contact_center_insights_v1.types.contact_center_insights import CalculateStatsRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import CalculateStatsResponse -from google.cloud.contact_center_insights_v1.types.contact_center_insights import CreateAnalysisOperationMetadata -from google.cloud.contact_center_insights_v1.types.contact_center_insights import CreateAnalysisRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import CreateConversationRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import CreateIssueModelMetadata -from google.cloud.contact_center_insights_v1.types.contact_center_insights import CreateIssueModelRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import CreatePhraseMatcherRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import CreateViewRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeleteAnalysisRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeleteConversationRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeleteIssueModelMetadata -from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeleteIssueModelRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeleteIssueRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeletePhraseMatcherRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeleteViewRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeployIssueModelMetadata -from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeployIssueModelRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import DeployIssueModelResponse -from google.cloud.contact_center_insights_v1.types.contact_center_insights import ExportInsightsDataMetadata -from google.cloud.contact_center_insights_v1.types.contact_center_insights import ExportInsightsDataRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import ExportInsightsDataResponse -from google.cloud.contact_center_insights_v1.types.contact_center_insights import GetAnalysisRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import GetConversationRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import GetIssueModelRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import GetIssueRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import GetPhraseMatcherRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import GetSettingsRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import GetViewRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import IngestConversationsMetadata -from google.cloud.contact_center_insights_v1.types.contact_center_insights import IngestConversationsRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import IngestConversationsResponse -from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListAnalysesRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListAnalysesResponse -from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListConversationsRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListConversationsResponse -from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListIssueModelsRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListIssueModelsResponse -from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListIssuesRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListIssuesResponse -from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListPhraseMatchersRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListPhraseMatchersResponse -from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListViewsRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import ListViewsResponse -from google.cloud.contact_center_insights_v1.types.contact_center_insights import UndeployIssueModelMetadata -from google.cloud.contact_center_insights_v1.types.contact_center_insights import UndeployIssueModelRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import UndeployIssueModelResponse -from google.cloud.contact_center_insights_v1.types.contact_center_insights import UpdateConversationRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import UpdateIssueModelRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import UpdateIssueRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import UpdatePhraseMatcherRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import UpdateSettingsRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import UpdateViewRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import UploadConversationMetadata -from google.cloud.contact_center_insights_v1.types.contact_center_insights import UploadConversationRequest -from google.cloud.contact_center_insights_v1.types.contact_center_insights import ConversationView -from google.cloud.contact_center_insights_v1.types.resources import Analysis -from google.cloud.contact_center_insights_v1.types.resources import AnalysisResult -from google.cloud.contact_center_insights_v1.types.resources import AnnotationBoundary -from google.cloud.contact_center_insights_v1.types.resources import AnnotatorSelector -from google.cloud.contact_center_insights_v1.types.resources import AnswerFeedback -from google.cloud.contact_center_insights_v1.types.resources import ArticleSuggestionData -from google.cloud.contact_center_insights_v1.types.resources import CallAnnotation -from google.cloud.contact_center_insights_v1.types.resources import Conversation -from google.cloud.contact_center_insights_v1.types.resources import ConversationDataSource -from google.cloud.contact_center_insights_v1.types.resources import ConversationLevelSentiment -from google.cloud.contact_center_insights_v1.types.resources import ConversationParticipant -from google.cloud.contact_center_insights_v1.types.resources import ConversationSummarizationSuggestionData -from google.cloud.contact_center_insights_v1.types.resources import DialogflowIntent -from google.cloud.contact_center_insights_v1.types.resources import DialogflowInteractionData -from google.cloud.contact_center_insights_v1.types.resources import DialogflowSource -from google.cloud.contact_center_insights_v1.types.resources import Entity -from google.cloud.contact_center_insights_v1.types.resources import EntityMentionData -from google.cloud.contact_center_insights_v1.types.resources import ExactMatchConfig -from google.cloud.contact_center_insights_v1.types.resources import FaqAnswerData -from google.cloud.contact_center_insights_v1.types.resources import GcsSource -from google.cloud.contact_center_insights_v1.types.resources import HoldData -from google.cloud.contact_center_insights_v1.types.resources import Intent -from google.cloud.contact_center_insights_v1.types.resources import IntentMatchData -from google.cloud.contact_center_insights_v1.types.resources import InterruptionData -from google.cloud.contact_center_insights_v1.types.resources import Issue -from google.cloud.contact_center_insights_v1.types.resources import IssueAssignment -from google.cloud.contact_center_insights_v1.types.resources import IssueMatchData -from google.cloud.contact_center_insights_v1.types.resources import IssueModel -from google.cloud.contact_center_insights_v1.types.resources import IssueModelLabelStats -from google.cloud.contact_center_insights_v1.types.resources import IssueModelResult -from google.cloud.contact_center_insights_v1.types.resources import PhraseMatchData -from google.cloud.contact_center_insights_v1.types.resources import PhraseMatcher -from google.cloud.contact_center_insights_v1.types.resources import PhraseMatchRule -from google.cloud.contact_center_insights_v1.types.resources import PhraseMatchRuleConfig -from google.cloud.contact_center_insights_v1.types.resources import PhraseMatchRuleGroup -from google.cloud.contact_center_insights_v1.types.resources import RedactionConfig -from google.cloud.contact_center_insights_v1.types.resources import RuntimeAnnotation -from google.cloud.contact_center_insights_v1.types.resources import SentimentData -from google.cloud.contact_center_insights_v1.types.resources import Settings -from google.cloud.contact_center_insights_v1.types.resources import SilenceData -from google.cloud.contact_center_insights_v1.types.resources import SmartComposeSuggestionData -from google.cloud.contact_center_insights_v1.types.resources import SmartReplyData -from google.cloud.contact_center_insights_v1.types.resources import SpeechConfig -from google.cloud.contact_center_insights_v1.types.resources import View - -__all__ = ('ContactCenterInsightsClient', - 'ContactCenterInsightsAsyncClient', - 'BulkAnalyzeConversationsMetadata', - 'BulkAnalyzeConversationsRequest', - 'BulkAnalyzeConversationsResponse', - 'CalculateIssueModelStatsRequest', - 'CalculateIssueModelStatsResponse', - 'CalculateStatsRequest', - 'CalculateStatsResponse', - 'CreateAnalysisOperationMetadata', - 'CreateAnalysisRequest', - 'CreateConversationRequest', - 'CreateIssueModelMetadata', - 'CreateIssueModelRequest', - 'CreatePhraseMatcherRequest', - 'CreateViewRequest', - 'DeleteAnalysisRequest', - 'DeleteConversationRequest', - 'DeleteIssueModelMetadata', - 'DeleteIssueModelRequest', - 'DeleteIssueRequest', - 'DeletePhraseMatcherRequest', - 'DeleteViewRequest', - 'DeployIssueModelMetadata', - 'DeployIssueModelRequest', - 'DeployIssueModelResponse', - 'ExportInsightsDataMetadata', - 'ExportInsightsDataRequest', - 'ExportInsightsDataResponse', - 'GetAnalysisRequest', - 'GetConversationRequest', - 'GetIssueModelRequest', - 'GetIssueRequest', - 'GetPhraseMatcherRequest', - 'GetSettingsRequest', - 'GetViewRequest', - 'IngestConversationsMetadata', - 'IngestConversationsRequest', - 'IngestConversationsResponse', - 'ListAnalysesRequest', - 'ListAnalysesResponse', - 'ListConversationsRequest', - 'ListConversationsResponse', - 'ListIssueModelsRequest', - 'ListIssueModelsResponse', - 'ListIssuesRequest', - 'ListIssuesResponse', - 'ListPhraseMatchersRequest', - 'ListPhraseMatchersResponse', - 'ListViewsRequest', - 'ListViewsResponse', - 'UndeployIssueModelMetadata', - 'UndeployIssueModelRequest', - 'UndeployIssueModelResponse', - 'UpdateConversationRequest', - 'UpdateIssueModelRequest', - 'UpdateIssueRequest', - 'UpdatePhraseMatcherRequest', - 'UpdateSettingsRequest', - 'UpdateViewRequest', - 'UploadConversationMetadata', - 'UploadConversationRequest', - 'ConversationView', - 'Analysis', - 'AnalysisResult', - 'AnnotationBoundary', - 'AnnotatorSelector', - 'AnswerFeedback', - 'ArticleSuggestionData', - 'CallAnnotation', - 'Conversation', - 'ConversationDataSource', - 'ConversationLevelSentiment', - 'ConversationParticipant', - 'ConversationSummarizationSuggestionData', - 'DialogflowIntent', - 'DialogflowInteractionData', - 'DialogflowSource', - 'Entity', - 'EntityMentionData', - 'ExactMatchConfig', - 'FaqAnswerData', - 'GcsSource', - 'HoldData', - 'Intent', - 'IntentMatchData', - 'InterruptionData', - 'Issue', - 'IssueAssignment', - 'IssueMatchData', - 'IssueModel', - 'IssueModelLabelStats', - 'IssueModelResult', - 'PhraseMatchData', - 'PhraseMatcher', - 'PhraseMatchRule', - 'PhraseMatchRuleConfig', - 'PhraseMatchRuleGroup', - 'RedactionConfig', - 'RuntimeAnnotation', - 'SentimentData', - 'Settings', - 'SilenceData', - 'SmartComposeSuggestionData', - 'SmartReplyData', - 'SpeechConfig', - 'View', -) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/gapic_version.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/gapic_version.py deleted file mode 100644 index 360a0d13ebdd..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/gapic_version.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -__version__ = "0.0.0" # {x-release-please-version} diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/py.typed b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/py.typed deleted file mode 100644 index d02b3b435cbb..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-contact-center-insights package uses inline types. diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/__init__.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/__init__.py deleted file mode 100644 index fd1cbb00e141..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/__init__.py +++ /dev/null @@ -1,238 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -from google.cloud.contact_center_insights_v1 import gapic_version as package_version - -__version__ = package_version.__version__ - - -from .services.contact_center_insights import ContactCenterInsightsClient -from .services.contact_center_insights import ContactCenterInsightsAsyncClient - -from .types.contact_center_insights import BulkAnalyzeConversationsMetadata -from .types.contact_center_insights import BulkAnalyzeConversationsRequest -from .types.contact_center_insights import BulkAnalyzeConversationsResponse -from .types.contact_center_insights import CalculateIssueModelStatsRequest -from .types.contact_center_insights import CalculateIssueModelStatsResponse -from .types.contact_center_insights import CalculateStatsRequest -from .types.contact_center_insights import CalculateStatsResponse -from .types.contact_center_insights import CreateAnalysisOperationMetadata -from .types.contact_center_insights import CreateAnalysisRequest -from .types.contact_center_insights import CreateConversationRequest -from .types.contact_center_insights import CreateIssueModelMetadata -from .types.contact_center_insights import CreateIssueModelRequest -from .types.contact_center_insights import CreatePhraseMatcherRequest -from .types.contact_center_insights import CreateViewRequest -from .types.contact_center_insights import DeleteAnalysisRequest -from .types.contact_center_insights import DeleteConversationRequest -from .types.contact_center_insights import DeleteIssueModelMetadata -from .types.contact_center_insights import DeleteIssueModelRequest -from .types.contact_center_insights import DeleteIssueRequest -from .types.contact_center_insights import DeletePhraseMatcherRequest -from .types.contact_center_insights import DeleteViewRequest -from .types.contact_center_insights import DeployIssueModelMetadata -from .types.contact_center_insights import DeployIssueModelRequest -from .types.contact_center_insights import DeployIssueModelResponse -from .types.contact_center_insights import ExportInsightsDataMetadata -from .types.contact_center_insights import ExportInsightsDataRequest -from .types.contact_center_insights import ExportInsightsDataResponse -from .types.contact_center_insights import GetAnalysisRequest -from .types.contact_center_insights import GetConversationRequest -from .types.contact_center_insights import GetIssueModelRequest -from .types.contact_center_insights import GetIssueRequest -from .types.contact_center_insights import GetPhraseMatcherRequest -from .types.contact_center_insights import GetSettingsRequest -from .types.contact_center_insights import GetViewRequest -from .types.contact_center_insights import IngestConversationsMetadata -from .types.contact_center_insights import IngestConversationsRequest -from .types.contact_center_insights import IngestConversationsResponse -from .types.contact_center_insights import ListAnalysesRequest -from .types.contact_center_insights import ListAnalysesResponse -from .types.contact_center_insights import ListConversationsRequest -from .types.contact_center_insights import ListConversationsResponse -from .types.contact_center_insights import ListIssueModelsRequest -from .types.contact_center_insights import ListIssueModelsResponse -from .types.contact_center_insights import ListIssuesRequest -from .types.contact_center_insights import ListIssuesResponse -from .types.contact_center_insights import ListPhraseMatchersRequest -from .types.contact_center_insights import ListPhraseMatchersResponse -from .types.contact_center_insights import ListViewsRequest -from .types.contact_center_insights import ListViewsResponse -from .types.contact_center_insights import UndeployIssueModelMetadata -from .types.contact_center_insights import UndeployIssueModelRequest -from .types.contact_center_insights import UndeployIssueModelResponse -from .types.contact_center_insights import UpdateConversationRequest -from .types.contact_center_insights import UpdateIssueModelRequest -from .types.contact_center_insights import UpdateIssueRequest -from .types.contact_center_insights import UpdatePhraseMatcherRequest -from .types.contact_center_insights import UpdateSettingsRequest -from .types.contact_center_insights import UpdateViewRequest -from .types.contact_center_insights import UploadConversationMetadata -from .types.contact_center_insights import UploadConversationRequest -from .types.contact_center_insights import ConversationView -from .types.resources import Analysis -from .types.resources import AnalysisResult -from .types.resources import AnnotationBoundary -from .types.resources import AnnotatorSelector -from .types.resources import AnswerFeedback -from .types.resources import ArticleSuggestionData -from .types.resources import CallAnnotation -from .types.resources import Conversation -from .types.resources import ConversationDataSource -from .types.resources import ConversationLevelSentiment -from .types.resources import ConversationParticipant -from .types.resources import ConversationSummarizationSuggestionData -from .types.resources import DialogflowIntent -from .types.resources import DialogflowInteractionData -from .types.resources import DialogflowSource -from .types.resources import Entity -from .types.resources import EntityMentionData -from .types.resources import ExactMatchConfig -from .types.resources import FaqAnswerData -from .types.resources import GcsSource -from .types.resources import HoldData -from .types.resources import Intent -from .types.resources import IntentMatchData -from .types.resources import InterruptionData -from .types.resources import Issue -from .types.resources import IssueAssignment -from .types.resources import IssueMatchData -from .types.resources import IssueModel -from .types.resources import IssueModelLabelStats -from .types.resources import IssueModelResult -from .types.resources import PhraseMatchData -from .types.resources import PhraseMatcher -from .types.resources import PhraseMatchRule -from .types.resources import PhraseMatchRuleConfig -from .types.resources import PhraseMatchRuleGroup -from .types.resources import RedactionConfig -from .types.resources import RuntimeAnnotation -from .types.resources import SentimentData -from .types.resources import Settings -from .types.resources import SilenceData -from .types.resources import SmartComposeSuggestionData -from .types.resources import SmartReplyData -from .types.resources import SpeechConfig -from .types.resources import View - -__all__ = ( - 'ContactCenterInsightsAsyncClient', -'Analysis', -'AnalysisResult', -'AnnotationBoundary', -'AnnotatorSelector', -'AnswerFeedback', -'ArticleSuggestionData', -'BulkAnalyzeConversationsMetadata', -'BulkAnalyzeConversationsRequest', -'BulkAnalyzeConversationsResponse', -'CalculateIssueModelStatsRequest', -'CalculateIssueModelStatsResponse', -'CalculateStatsRequest', -'CalculateStatsResponse', -'CallAnnotation', -'ContactCenterInsightsClient', -'Conversation', -'ConversationDataSource', -'ConversationLevelSentiment', -'ConversationParticipant', -'ConversationSummarizationSuggestionData', -'ConversationView', -'CreateAnalysisOperationMetadata', -'CreateAnalysisRequest', -'CreateConversationRequest', -'CreateIssueModelMetadata', -'CreateIssueModelRequest', -'CreatePhraseMatcherRequest', -'CreateViewRequest', -'DeleteAnalysisRequest', -'DeleteConversationRequest', -'DeleteIssueModelMetadata', -'DeleteIssueModelRequest', -'DeleteIssueRequest', -'DeletePhraseMatcherRequest', -'DeleteViewRequest', -'DeployIssueModelMetadata', -'DeployIssueModelRequest', -'DeployIssueModelResponse', -'DialogflowIntent', -'DialogflowInteractionData', -'DialogflowSource', -'Entity', -'EntityMentionData', -'ExactMatchConfig', -'ExportInsightsDataMetadata', -'ExportInsightsDataRequest', -'ExportInsightsDataResponse', -'FaqAnswerData', -'GcsSource', -'GetAnalysisRequest', -'GetConversationRequest', -'GetIssueModelRequest', -'GetIssueRequest', -'GetPhraseMatcherRequest', -'GetSettingsRequest', -'GetViewRequest', -'HoldData', -'IngestConversationsMetadata', -'IngestConversationsRequest', -'IngestConversationsResponse', -'Intent', -'IntentMatchData', -'InterruptionData', -'Issue', -'IssueAssignment', -'IssueMatchData', -'IssueModel', -'IssueModelLabelStats', -'IssueModelResult', -'ListAnalysesRequest', -'ListAnalysesResponse', -'ListConversationsRequest', -'ListConversationsResponse', -'ListIssueModelsRequest', -'ListIssueModelsResponse', -'ListIssuesRequest', -'ListIssuesResponse', -'ListPhraseMatchersRequest', -'ListPhraseMatchersResponse', -'ListViewsRequest', -'ListViewsResponse', -'PhraseMatchData', -'PhraseMatchRule', -'PhraseMatchRuleConfig', -'PhraseMatchRuleGroup', -'PhraseMatcher', -'RedactionConfig', -'RuntimeAnnotation', -'SentimentData', -'Settings', -'SilenceData', -'SmartComposeSuggestionData', -'SmartReplyData', -'SpeechConfig', -'UndeployIssueModelMetadata', -'UndeployIssueModelRequest', -'UndeployIssueModelResponse', -'UpdateConversationRequest', -'UpdateIssueModelRequest', -'UpdateIssueRequest', -'UpdatePhraseMatcherRequest', -'UpdateSettingsRequest', -'UpdateViewRequest', -'UploadConversationMetadata', -'UploadConversationRequest', -'View', -) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/gapic_metadata.json b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/gapic_metadata.json deleted file mode 100644 index bc4e05861648..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/gapic_metadata.json +++ /dev/null @@ -1,598 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.contact_center_insights_v1", - "protoPackage": "google.cloud.contactcenterinsights.v1", - "schema": "1.0", - "services": { - "ContactCenterInsights": { - "clients": { - "grpc": { - "libraryClient": "ContactCenterInsightsClient", - "rpcs": { - "BulkAnalyzeConversations": { - "methods": [ - "bulk_analyze_conversations" - ] - }, - "CalculateIssueModelStats": { - "methods": [ - "calculate_issue_model_stats" - ] - }, - "CalculateStats": { - "methods": [ - "calculate_stats" - ] - }, - "CreateAnalysis": { - "methods": [ - "create_analysis" - ] - }, - "CreateConversation": { - "methods": [ - "create_conversation" - ] - }, - "CreateIssueModel": { - "methods": [ - "create_issue_model" - ] - }, - "CreatePhraseMatcher": { - "methods": [ - "create_phrase_matcher" - ] - }, - "CreateView": { - "methods": [ - "create_view" - ] - }, - "DeleteAnalysis": { - "methods": [ - "delete_analysis" - ] - }, - "DeleteConversation": { - "methods": [ - "delete_conversation" - ] - }, - "DeleteIssue": { - "methods": [ - "delete_issue" - ] - }, - "DeleteIssueModel": { - "methods": [ - "delete_issue_model" - ] - }, - "DeletePhraseMatcher": { - "methods": [ - "delete_phrase_matcher" - ] - }, - "DeleteView": { - "methods": [ - "delete_view" - ] - }, - "DeployIssueModel": { - "methods": [ - "deploy_issue_model" - ] - }, - "ExportInsightsData": { - "methods": [ - "export_insights_data" - ] - }, - "GetAnalysis": { - "methods": [ - "get_analysis" - ] - }, - "GetConversation": { - "methods": [ - "get_conversation" - ] - }, - "GetIssue": { - "methods": [ - "get_issue" - ] - }, - "GetIssueModel": { - "methods": [ - "get_issue_model" - ] - }, - "GetPhraseMatcher": { - "methods": [ - "get_phrase_matcher" - ] - }, - "GetSettings": { - "methods": [ - "get_settings" - ] - }, - "GetView": { - "methods": [ - "get_view" - ] - }, - "IngestConversations": { - "methods": [ - "ingest_conversations" - ] - }, - "ListAnalyses": { - "methods": [ - "list_analyses" - ] - }, - "ListConversations": { - "methods": [ - "list_conversations" - ] - }, - "ListIssueModels": { - "methods": [ - "list_issue_models" - ] - }, - "ListIssues": { - "methods": [ - "list_issues" - ] - }, - "ListPhraseMatchers": { - "methods": [ - "list_phrase_matchers" - ] - }, - "ListViews": { - "methods": [ - "list_views" - ] - }, - "UndeployIssueModel": { - "methods": [ - "undeploy_issue_model" - ] - }, - "UpdateConversation": { - "methods": [ - "update_conversation" - ] - }, - "UpdateIssue": { - "methods": [ - "update_issue" - ] - }, - "UpdateIssueModel": { - "methods": [ - "update_issue_model" - ] - }, - "UpdatePhraseMatcher": { - "methods": [ - "update_phrase_matcher" - ] - }, - "UpdateSettings": { - "methods": [ - "update_settings" - ] - }, - "UpdateView": { - "methods": [ - "update_view" - ] - }, - "UploadConversation": { - "methods": [ - "upload_conversation" - ] - } - } - }, - "grpc-async": { - "libraryClient": "ContactCenterInsightsAsyncClient", - "rpcs": { - "BulkAnalyzeConversations": { - "methods": [ - "bulk_analyze_conversations" - ] - }, - "CalculateIssueModelStats": { - "methods": [ - "calculate_issue_model_stats" - ] - }, - "CalculateStats": { - "methods": [ - "calculate_stats" - ] - }, - "CreateAnalysis": { - "methods": [ - "create_analysis" - ] - }, - "CreateConversation": { - "methods": [ - "create_conversation" - ] - }, - "CreateIssueModel": { - "methods": [ - "create_issue_model" - ] - }, - "CreatePhraseMatcher": { - "methods": [ - "create_phrase_matcher" - ] - }, - "CreateView": { - "methods": [ - "create_view" - ] - }, - "DeleteAnalysis": { - "methods": [ - "delete_analysis" - ] - }, - "DeleteConversation": { - "methods": [ - "delete_conversation" - ] - }, - "DeleteIssue": { - "methods": [ - "delete_issue" - ] - }, - "DeleteIssueModel": { - "methods": [ - "delete_issue_model" - ] - }, - "DeletePhraseMatcher": { - "methods": [ - "delete_phrase_matcher" - ] - }, - "DeleteView": { - "methods": [ - "delete_view" - ] - }, - "DeployIssueModel": { - "methods": [ - "deploy_issue_model" - ] - }, - "ExportInsightsData": { - "methods": [ - "export_insights_data" - ] - }, - "GetAnalysis": { - "methods": [ - "get_analysis" - ] - }, - "GetConversation": { - "methods": [ - "get_conversation" - ] - }, - "GetIssue": { - "methods": [ - "get_issue" - ] - }, - "GetIssueModel": { - "methods": [ - "get_issue_model" - ] - }, - "GetPhraseMatcher": { - "methods": [ - "get_phrase_matcher" - ] - }, - "GetSettings": { - "methods": [ - "get_settings" - ] - }, - "GetView": { - "methods": [ - "get_view" - ] - }, - "IngestConversations": { - "methods": [ - "ingest_conversations" - ] - }, - "ListAnalyses": { - "methods": [ - "list_analyses" - ] - }, - "ListConversations": { - "methods": [ - "list_conversations" - ] - }, - "ListIssueModels": { - "methods": [ - "list_issue_models" - ] - }, - "ListIssues": { - "methods": [ - "list_issues" - ] - }, - "ListPhraseMatchers": { - "methods": [ - "list_phrase_matchers" - ] - }, - "ListViews": { - "methods": [ - "list_views" - ] - }, - "UndeployIssueModel": { - "methods": [ - "undeploy_issue_model" - ] - }, - "UpdateConversation": { - "methods": [ - "update_conversation" - ] - }, - "UpdateIssue": { - "methods": [ - "update_issue" - ] - }, - "UpdateIssueModel": { - "methods": [ - "update_issue_model" - ] - }, - "UpdatePhraseMatcher": { - "methods": [ - "update_phrase_matcher" - ] - }, - "UpdateSettings": { - "methods": [ - "update_settings" - ] - }, - "UpdateView": { - "methods": [ - "update_view" - ] - }, - "UploadConversation": { - "methods": [ - "upload_conversation" - ] - } - } - }, - "rest": { - "libraryClient": "ContactCenterInsightsClient", - "rpcs": { - "BulkAnalyzeConversations": { - "methods": [ - "bulk_analyze_conversations" - ] - }, - "CalculateIssueModelStats": { - "methods": [ - "calculate_issue_model_stats" - ] - }, - "CalculateStats": { - "methods": [ - "calculate_stats" - ] - }, - "CreateAnalysis": { - "methods": [ - "create_analysis" - ] - }, - "CreateConversation": { - "methods": [ - "create_conversation" - ] - }, - "CreateIssueModel": { - "methods": [ - "create_issue_model" - ] - }, - "CreatePhraseMatcher": { - "methods": [ - "create_phrase_matcher" - ] - }, - "CreateView": { - "methods": [ - "create_view" - ] - }, - "DeleteAnalysis": { - "methods": [ - "delete_analysis" - ] - }, - "DeleteConversation": { - "methods": [ - "delete_conversation" - ] - }, - "DeleteIssue": { - "methods": [ - "delete_issue" - ] - }, - "DeleteIssueModel": { - "methods": [ - "delete_issue_model" - ] - }, - "DeletePhraseMatcher": { - "methods": [ - "delete_phrase_matcher" - ] - }, - "DeleteView": { - "methods": [ - "delete_view" - ] - }, - "DeployIssueModel": { - "methods": [ - "deploy_issue_model" - ] - }, - "ExportInsightsData": { - "methods": [ - "export_insights_data" - ] - }, - "GetAnalysis": { - "methods": [ - "get_analysis" - ] - }, - "GetConversation": { - "methods": [ - "get_conversation" - ] - }, - "GetIssue": { - "methods": [ - "get_issue" - ] - }, - "GetIssueModel": { - "methods": [ - "get_issue_model" - ] - }, - "GetPhraseMatcher": { - "methods": [ - "get_phrase_matcher" - ] - }, - "GetSettings": { - "methods": [ - "get_settings" - ] - }, - "GetView": { - "methods": [ - "get_view" - ] - }, - "IngestConversations": { - "methods": [ - "ingest_conversations" - ] - }, - "ListAnalyses": { - "methods": [ - "list_analyses" - ] - }, - "ListConversations": { - "methods": [ - "list_conversations" - ] - }, - "ListIssueModels": { - "methods": [ - "list_issue_models" - ] - }, - "ListIssues": { - "methods": [ - "list_issues" - ] - }, - "ListPhraseMatchers": { - "methods": [ - "list_phrase_matchers" - ] - }, - "ListViews": { - "methods": [ - "list_views" - ] - }, - "UndeployIssueModel": { - "methods": [ - "undeploy_issue_model" - ] - }, - "UpdateConversation": { - "methods": [ - "update_conversation" - ] - }, - "UpdateIssue": { - "methods": [ - "update_issue" - ] - }, - "UpdateIssueModel": { - "methods": [ - "update_issue_model" - ] - }, - "UpdatePhraseMatcher": { - "methods": [ - "update_phrase_matcher" - ] - }, - "UpdateSettings": { - "methods": [ - "update_settings" - ] - }, - "UpdateView": { - "methods": [ - "update_view" - ] - }, - "UploadConversation": { - "methods": [ - "upload_conversation" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/gapic_version.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/gapic_version.py deleted file mode 100644 index 360a0d13ebdd..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/gapic_version.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -__version__ = "0.0.0" # {x-release-please-version} diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/py.typed b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/py.typed deleted file mode 100644 index d02b3b435cbb..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-contact-center-insights package uses inline types. diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/__init__.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/__init__.py deleted file mode 100644 index 89a37dc92c5a..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/__init__.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/__init__.py deleted file mode 100644 index 8c4af4871216..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -from .client import ContactCenterInsightsClient -from .async_client import ContactCenterInsightsAsyncClient - -__all__ = ( - 'ContactCenterInsightsClient', - 'ContactCenterInsightsAsyncClient', -) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py deleted file mode 100644 index bf79a6deebf0..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py +++ /dev/null @@ -1,4421 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -from collections import OrderedDict -import functools -import re -from typing import Dict, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union - -from google.cloud.contact_center_insights_v1 import gapic_version as package_version - -from google.api_core.client_options import ClientOptions -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.contact_center_insights_v1.services.contact_center_insights import pagers -from google.cloud.contact_center_insights_v1.types import contact_center_insights -from google.cloud.contact_center_insights_v1.types import resources -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import ContactCenterInsightsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import ContactCenterInsightsGrpcAsyncIOTransport -from .client import ContactCenterInsightsClient - - -class ContactCenterInsightsAsyncClient: - """An API that lets users analyze and explore their business - conversation data. - """ - - _client: ContactCenterInsightsClient - - DEFAULT_ENDPOINT = ContactCenterInsightsClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = ContactCenterInsightsClient.DEFAULT_MTLS_ENDPOINT - - analysis_path = staticmethod(ContactCenterInsightsClient.analysis_path) - parse_analysis_path = staticmethod(ContactCenterInsightsClient.parse_analysis_path) - conversation_path = staticmethod(ContactCenterInsightsClient.conversation_path) - parse_conversation_path = staticmethod(ContactCenterInsightsClient.parse_conversation_path) - conversation_profile_path = staticmethod(ContactCenterInsightsClient.conversation_profile_path) - parse_conversation_profile_path = staticmethod(ContactCenterInsightsClient.parse_conversation_profile_path) - issue_path = staticmethod(ContactCenterInsightsClient.issue_path) - parse_issue_path = staticmethod(ContactCenterInsightsClient.parse_issue_path) - issue_model_path = staticmethod(ContactCenterInsightsClient.issue_model_path) - parse_issue_model_path = staticmethod(ContactCenterInsightsClient.parse_issue_model_path) - participant_path = staticmethod(ContactCenterInsightsClient.participant_path) - parse_participant_path = staticmethod(ContactCenterInsightsClient.parse_participant_path) - phrase_matcher_path = staticmethod(ContactCenterInsightsClient.phrase_matcher_path) - 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) - parse_view_path = staticmethod(ContactCenterInsightsClient.parse_view_path) - common_billing_account_path = staticmethod(ContactCenterInsightsClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(ContactCenterInsightsClient.parse_common_billing_account_path) - common_folder_path = staticmethod(ContactCenterInsightsClient.common_folder_path) - parse_common_folder_path = staticmethod(ContactCenterInsightsClient.parse_common_folder_path) - common_organization_path = staticmethod(ContactCenterInsightsClient.common_organization_path) - parse_common_organization_path = staticmethod(ContactCenterInsightsClient.parse_common_organization_path) - common_project_path = staticmethod(ContactCenterInsightsClient.common_project_path) - parse_common_project_path = staticmethod(ContactCenterInsightsClient.parse_common_project_path) - common_location_path = staticmethod(ContactCenterInsightsClient.common_location_path) - parse_common_location_path = staticmethod(ContactCenterInsightsClient.parse_common_location_path) - - @classmethod - def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials - info. - - Args: - info (dict): The service account private key info. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - ContactCenterInsightsAsyncClient: The constructed client. - """ - return ContactCenterInsightsClient.from_service_account_info.__func__(ContactCenterInsightsAsyncClient, info, *args, **kwargs) # type: ignore - - @classmethod - def from_service_account_file(cls, filename: str, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - ContactCenterInsightsAsyncClient: The constructed client. - """ - return ContactCenterInsightsClient.from_service_account_file.__func__(ContactCenterInsightsAsyncClient, filename, *args, **kwargs) # type: ignore - - from_service_account_json = from_service_account_file - - @classmethod - def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[ClientOptions] = None): - """Return the API endpoint and client cert source for mutual TLS. - - The client cert source is determined in the following order: - (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the - client cert source is None. - (2) if `client_options.client_cert_source` is provided, use the provided one; if the - default client cert source exists, use the default one; otherwise the client cert - source is None. - - The API endpoint is determined in the following order: - (1) if `client_options.api_endpoint` if provided, use the provided one. - (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the - default mTLS endpoint; if the environment variable is "never", use the default API - endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise - use the default API endpoint. - - More details can be found at https://google.aip.dev/auth/4114. - - Args: - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. Only the `api_endpoint` and `client_cert_source` properties may be used - in this method. - - Returns: - Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the - client cert source to use. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If any errors happen. - """ - return ContactCenterInsightsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> ContactCenterInsightsTransport: - """Returns the transport used by the client instance. - - Returns: - ContactCenterInsightsTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(ContactCenterInsightsClient).get_transport_class, type(ContactCenterInsightsClient)) - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, ContactCenterInsightsTransport] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the contact center insights client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, ~.ContactCenterInsightsTransport]): The - transport to use. If set to None, a transport is chosen - automatically. - client_options (ClientOptions): Custom options for the client. It - won't take effect if a ``transport`` instance is provided. - (1) The ``api_endpoint`` property can be used to override the - default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT - environment variable can also be used to override the endpoint: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto switch to the - default mTLS endpoint if client certificate is present, this is - the default value). However, the ``api_endpoint`` property takes - precedence if provided. - (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide client certificate for mutual TLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - """ - self._client = ContactCenterInsightsClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def create_conversation(self, - request: Optional[Union[contact_center_insights.CreateConversationRequest, dict]] = None, - *, - parent: Optional[str] = None, - conversation: Optional[resources.Conversation] = None, - conversation_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Conversation: - r"""Creates a conversation. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_create_conversation(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CreateConversationRequest( - parent="parent_value", - ) - - # Make the request - response = await client.create_conversation(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.CreateConversationRequest, dict]]): - The request object. Request to create a conversation. - parent (:class:`str`): - Required. The parent resource of the - conversation. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - conversation (:class:`google.cloud.contact_center_insights_v1.types.Conversation`): - Required. The conversation resource - to create. - - This corresponds to the ``conversation`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - conversation_id (:class:`str`): - A unique ID for the new conversation. This ID will - become the final component of the conversation's - resource name. If no ID is specified, a server-generated - ID will be used. - - This value should be 4-64 characters and must match the - regular expression ``^[a-z0-9-]{4,64}$``. Valid - characters are ``[a-z][0-9]-`` - - This corresponds to the ``conversation_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.Conversation: - The conversation resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, conversation, conversation_id]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.CreateConversationRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if conversation is not None: - request.conversation = conversation - if conversation_id is not None: - request.conversation_id = conversation_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.create_conversation, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def upload_conversation(self, - request: Optional[Union[contact_center_insights.UploadConversationRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Create a longrunning conversation upload operation. - This method differs from CreateConversation by allowing - audio transcription and optional DLP redaction. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_upload_conversation(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UploadConversationRequest( - parent="parent_value", - ) - - # Make the request - operation = client.upload_conversation(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.UploadConversationRequest, dict]]): - The request object. Request to upload a conversation. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.contact_center_insights_v1.types.Conversation` - The conversation resource. - - """ - # Create or coerce a protobuf request object. - request = contact_center_insights.UploadConversationRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.upload_conversation, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - resources.Conversation, - metadata_type=contact_center_insights.UploadConversationMetadata, - ) - - # Done; return the response. - return response - - async def update_conversation(self, - request: Optional[Union[contact_center_insights.UpdateConversationRequest, dict]] = None, - *, - conversation: Optional[resources.Conversation] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Conversation: - r"""Updates a conversation. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_update_conversation(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UpdateConversationRequest( - ) - - # Make the request - response = await client.update_conversation(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.UpdateConversationRequest, dict]]): - The request object. The request to update a conversation. - conversation (:class:`google.cloud.contact_center_insights_v1.types.Conversation`): - Required. The new values for the - conversation. - - This corresponds to the ``conversation`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The list of fields to be updated. - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.Conversation: - The conversation resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([conversation, update_mask]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.UpdateConversationRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if conversation is not None: - request.conversation = conversation - if update_mask is not None: - request.update_mask = update_mask - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.update_conversation, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("conversation.name", request.conversation.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_conversation(self, - request: Optional[Union[contact_center_insights.GetConversationRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Conversation: - r"""Gets a conversation. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_get_conversation(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetConversationRequest( - name="name_value", - ) - - # Make the request - response = await client.get_conversation(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetConversationRequest, dict]]): - The request object. The request to get a conversation. - name (:class:`str`): - Required. The name of the - conversation to get. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.Conversation: - The conversation resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.GetConversationRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.get_conversation, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_conversations(self, - request: Optional[Union[contact_center_insights.ListConversationsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListConversationsAsyncPager: - r"""Lists conversations. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_list_conversations(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListConversationsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_conversations(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.ListConversationsRequest, dict]]): - The request object. Request to list conversations. - parent (:class:`str`): - Required. The parent resource of the - conversation. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListConversationsAsyncPager: - The response of listing - conversations. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.ListConversationsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_conversations, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListConversationsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_conversation(self, - request: Optional[Union[contact_center_insights.DeleteConversationRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a conversation. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_delete_conversation(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeleteConversationRequest( - name="name_value", - ) - - # Make the request - await client.delete_conversation(request=request) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeleteConversationRequest, dict]]): - The request object. The request to delete a conversation. - name (:class:`str`): - Required. The name of the - conversation to delete. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.DeleteConversationRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.delete_conversation, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def create_analysis(self, - request: Optional[Union[contact_center_insights.CreateAnalysisRequest, dict]] = None, - *, - parent: Optional[str] = None, - analysis: Optional[resources.Analysis] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Creates an analysis. The long running operation is - done when the analysis has completed. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_create_analysis(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CreateAnalysisRequest( - parent="parent_value", - ) - - # Make the request - operation = client.create_analysis(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.CreateAnalysisRequest, dict]]): - The request object. The request to create an analysis. - parent (:class:`str`): - Required. The parent resource of the - analysis. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - analysis (:class:`google.cloud.contact_center_insights_v1.types.Analysis`): - Required. The analysis to create. - This corresponds to the ``analysis`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.contact_center_insights_v1.types.Analysis` - The analysis resource. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, analysis]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.CreateAnalysisRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if analysis is not None: - request.analysis = analysis - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.create_analysis, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - resources.Analysis, - metadata_type=contact_center_insights.CreateAnalysisOperationMetadata, - ) - - # Done; return the response. - return response - - async def get_analysis(self, - request: Optional[Union[contact_center_insights.GetAnalysisRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Analysis: - r"""Gets an analysis. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_get_analysis(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetAnalysisRequest( - name="name_value", - ) - - # Make the request - response = await client.get_analysis(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetAnalysisRequest, dict]]): - The request object. The request to get an analysis. - name (:class:`str`): - Required. The name of the analysis to - get. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.Analysis: - The analysis resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.GetAnalysisRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.get_analysis, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_analyses(self, - request: Optional[Union[contact_center_insights.ListAnalysesRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListAnalysesAsyncPager: - r"""Lists analyses. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_list_analyses(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListAnalysesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_analyses(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.ListAnalysesRequest, dict]]): - The request object. The request to list analyses. - parent (:class:`str`): - Required. The parent resource of the - analyses. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAnalysesAsyncPager: - The response to list analyses. - - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.ListAnalysesRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_analyses, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListAnalysesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_analysis(self, - request: Optional[Union[contact_center_insights.DeleteAnalysisRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes an analysis. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_delete_analysis(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeleteAnalysisRequest( - name="name_value", - ) - - # Make the request - await client.delete_analysis(request=request) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeleteAnalysisRequest, dict]]): - The request object. The request to delete an analysis. - name (:class:`str`): - Required. The name of the analysis to - delete. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.DeleteAnalysisRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.delete_analysis, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def bulk_analyze_conversations(self, - request: Optional[Union[contact_center_insights.BulkAnalyzeConversationsRequest, dict]] = None, - *, - parent: Optional[str] = None, - filter: Optional[str] = None, - analysis_percentage: Optional[float] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Analyzes multiple conversations in a single request. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_bulk_analyze_conversations(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.BulkAnalyzeConversationsRequest( - parent="parent_value", - filter="filter_value", - analysis_percentage=0.20170000000000002, - ) - - # Make the request - operation = client.bulk_analyze_conversations(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.BulkAnalyzeConversationsRequest, dict]]): - The request object. The request to analyze conversations - in bulk. - parent (:class:`str`): - Required. The parent resource to - create analyses in. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - filter (:class:`str`): - Required. Filter used to select the - subset of conversations to analyze. - - This corresponds to the ``filter`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - analysis_percentage (:class:`float`): - Required. Percentage of selected conversation to - analyze, between [0, 100]. - - This corresponds to the ``analysis_percentage`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.contact_center_insights_v1.types.BulkAnalyzeConversationsResponse` - The response for a bulk analyze conversations operation. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, filter, analysis_percentage]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.BulkAnalyzeConversationsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if filter is not None: - request.filter = filter - if analysis_percentage is not None: - request.analysis_percentage = analysis_percentage - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.bulk_analyze_conversations, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - contact_center_insights.BulkAnalyzeConversationsResponse, - metadata_type=contact_center_insights.BulkAnalyzeConversationsMetadata, - ) - - # Done; return the response. - return response - - async def ingest_conversations(self, - request: Optional[Union[contact_center_insights.IngestConversationsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Imports conversations and processes them according to - the user's configuration. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_ingest_conversations(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - gcs_source = contact_center_insights_v1.GcsSource() - gcs_source.bucket_uri = "bucket_uri_value" - - transcript_object_config = contact_center_insights_v1.TranscriptObjectConfig() - transcript_object_config.medium = "CHAT" - - request = contact_center_insights_v1.IngestConversationsRequest( - gcs_source=gcs_source, - transcript_object_config=transcript_object_config, - parent="parent_value", - ) - - # Make the request - operation = client.ingest_conversations(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.IngestConversationsRequest, dict]]): - The request object. The request to ingest conversations. - parent (:class:`str`): - Required. The parent resource for new - conversations. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.contact_center_insights_v1.types.IngestConversationsResponse` - The response to an IngestConversations operation. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.IngestConversationsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.ingest_conversations, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - contact_center_insights.IngestConversationsResponse, - metadata_type=contact_center_insights.IngestConversationsMetadata, - ) - - # Done; return the response. - return response - - async def export_insights_data(self, - request: Optional[Union[contact_center_insights.ExportInsightsDataRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Export insights data to a destination defined in the - request body. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_export_insights_data(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - big_query_destination = contact_center_insights_v1.BigQueryDestination() - big_query_destination.dataset = "dataset_value" - - request = contact_center_insights_v1.ExportInsightsDataRequest( - big_query_destination=big_query_destination, - parent="parent_value", - ) - - # Make the request - operation = client.export_insights_data(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest, dict]]): - The request object. The request to export insights. - parent (:class:`str`): - Required. The parent resource to - export data from. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.contact_center_insights_v1.types.ExportInsightsDataResponse` - Response for an export insights operation. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.ExportInsightsDataRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.export_insights_data, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - contact_center_insights.ExportInsightsDataResponse, - metadata_type=contact_center_insights.ExportInsightsDataMetadata, - ) - - # Done; return the response. - return response - - async def create_issue_model(self, - request: Optional[Union[contact_center_insights.CreateIssueModelRequest, dict]] = None, - *, - parent: Optional[str] = None, - issue_model: Optional[resources.IssueModel] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Creates an issue model. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_create_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CreateIssueModelRequest( - parent="parent_value", - ) - - # Make the request - operation = client.create_issue_model(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.CreateIssueModelRequest, dict]]): - The request object. The request to create an issue model. - parent (:class:`str`): - Required. The parent resource of the - issue model. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - issue_model (:class:`google.cloud.contact_center_insights_v1.types.IssueModel`): - Required. The issue model to create. - This corresponds to the ``issue_model`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.contact_center_insights_v1.types.IssueModel` - The issue model resource. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, issue_model]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.CreateIssueModelRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if issue_model is not None: - request.issue_model = issue_model - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.create_issue_model, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - resources.IssueModel, - metadata_type=contact_center_insights.CreateIssueModelMetadata, - ) - - # Done; return the response. - return response - - async def update_issue_model(self, - request: Optional[Union[contact_center_insights.UpdateIssueModelRequest, dict]] = None, - *, - issue_model: Optional[resources.IssueModel] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.IssueModel: - r"""Updates an issue model. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_update_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UpdateIssueModelRequest( - ) - - # Make the request - response = await client.update_issue_model(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.UpdateIssueModelRequest, dict]]): - The request object. The request to update an issue model. - issue_model (:class:`google.cloud.contact_center_insights_v1.types.IssueModel`): - Required. The new values for the - issue model. - - This corresponds to the ``issue_model`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The list of fields to be updated. - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.IssueModel: - The issue model resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([issue_model, update_mask]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.UpdateIssueModelRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if issue_model is not None: - request.issue_model = issue_model - if update_mask is not None: - request.update_mask = update_mask - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.update_issue_model, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("issue_model.name", request.issue_model.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_issue_model(self, - request: Optional[Union[contact_center_insights.GetIssueModelRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.IssueModel: - r"""Gets an issue model. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_get_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetIssueModelRequest( - name="name_value", - ) - - # Make the request - response = await client.get_issue_model(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetIssueModelRequest, dict]]): - The request object. The request to get an issue model. - name (:class:`str`): - Required. The name of the issue model - to get. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.IssueModel: - The issue model resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.GetIssueModelRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.get_issue_model, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_issue_models(self, - request: Optional[Union[contact_center_insights.ListIssueModelsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> contact_center_insights.ListIssueModelsResponse: - r"""Lists issue models. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_list_issue_models(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListIssueModelsRequest( - parent="parent_value", - ) - - # Make the request - response = await client.list_issue_models(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.ListIssueModelsRequest, dict]]): - The request object. Request to list issue models. - parent (:class:`str`): - Required. The parent resource of the - issue model. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.ListIssueModelsResponse: - The response of listing issue models. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.ListIssueModelsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_issue_models, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_issue_model(self, - request: Optional[Union[contact_center_insights.DeleteIssueModelRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes an issue model. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_delete_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeleteIssueModelRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_issue_model(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeleteIssueModelRequest, dict]]): - The request object. The request to delete an issue model. - name (:class:`str`): - Required. The name of the issue model - to delete. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.DeleteIssueModelRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.delete_issue_model, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=contact_center_insights.DeleteIssueModelMetadata, - ) - - # Done; return the response. - return response - - async def deploy_issue_model(self, - request: Optional[Union[contact_center_insights.DeployIssueModelRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Deploys an issue model. Returns an error if a model - is already deployed. An issue model can only be used in - analysis after it has been deployed. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_deploy_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeployIssueModelRequest( - name="name_value", - ) - - # Make the request - operation = client.deploy_issue_model(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeployIssueModelRequest, dict]]): - The request object. The request to deploy an issue model. - name (:class:`str`): - Required. The issue model to deploy. - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.contact_center_insights_v1.types.DeployIssueModelResponse` - The response to deploy an issue model. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.DeployIssueModelRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.deploy_issue_model, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - contact_center_insights.DeployIssueModelResponse, - metadata_type=contact_center_insights.DeployIssueModelMetadata, - ) - - # Done; return the response. - return response - - async def undeploy_issue_model(self, - request: Optional[Union[contact_center_insights.UndeployIssueModelRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Undeploys an issue model. - An issue model can not be used in analysis after it has - been undeployed. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_undeploy_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UndeployIssueModelRequest( - name="name_value", - ) - - # Make the request - operation = client.undeploy_issue_model(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.UndeployIssueModelRequest, dict]]): - The request object. The request to undeploy an issue - model. - name (:class:`str`): - Required. The issue model to - undeploy. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.contact_center_insights_v1.types.UndeployIssueModelResponse` - The response to undeploy an issue model. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.UndeployIssueModelRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.undeploy_issue_model, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - contact_center_insights.UndeployIssueModelResponse, - metadata_type=contact_center_insights.UndeployIssueModelMetadata, - ) - - # Done; return the response. - return response - - async def get_issue(self, - request: Optional[Union[contact_center_insights.GetIssueRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Issue: - r"""Gets an issue. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_get_issue(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetIssueRequest( - name="name_value", - ) - - # Make the request - response = await client.get_issue(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetIssueRequest, dict]]): - The request object. The request to get an issue. - name (:class:`str`): - Required. The name of the issue to - get. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.Issue: - The issue resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.GetIssueRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.get_issue, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_issues(self, - request: Optional[Union[contact_center_insights.ListIssuesRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> contact_center_insights.ListIssuesResponse: - r"""Lists issues. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_list_issues(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListIssuesRequest( - parent="parent_value", - ) - - # Make the request - response = await client.list_issues(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.ListIssuesRequest, dict]]): - The request object. Request to list issues. - parent (:class:`str`): - Required. The parent resource of the - issue. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.ListIssuesResponse: - The response of listing issues. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.ListIssuesRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_issues, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_issue(self, - request: Optional[Union[contact_center_insights.UpdateIssueRequest, dict]] = None, - *, - issue: Optional[resources.Issue] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Issue: - r"""Updates an issue. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_update_issue(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UpdateIssueRequest( - ) - - # Make the request - response = await client.update_issue(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.UpdateIssueRequest, dict]]): - The request object. The request to update an issue. - issue (:class:`google.cloud.contact_center_insights_v1.types.Issue`): - Required. The new values for the - issue. - - This corresponds to the ``issue`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The list of fields to be updated. - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.Issue: - The issue resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([issue, update_mask]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.UpdateIssueRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if issue is not None: - request.issue = issue - if update_mask is not None: - request.update_mask = update_mask - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.update_issue, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("issue.name", request.issue.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_issue(self, - request: Optional[Union[contact_center_insights.DeleteIssueRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes an issue. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_delete_issue(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeleteIssueRequest( - name="name_value", - ) - - # Make the request - await client.delete_issue(request=request) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeleteIssueRequest, dict]]): - The request object. The request to delete an issue. - name (:class:`str`): - Required. The name of the issue to - delete. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.DeleteIssueRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.delete_issue, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def calculate_issue_model_stats(self, - request: Optional[Union[contact_center_insights.CalculateIssueModelStatsRequest, dict]] = None, - *, - issue_model: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> contact_center_insights.CalculateIssueModelStatsResponse: - r"""Gets an issue model's statistics. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_calculate_issue_model_stats(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CalculateIssueModelStatsRequest( - issue_model="issue_model_value", - ) - - # Make the request - response = await client.calculate_issue_model_stats(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsRequest, dict]]): - The request object. Request to get statistics of an issue - model. - issue_model (:class:`str`): - Required. The resource name of the - issue model to query against. - - This corresponds to the ``issue_model`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsResponse: - Response of querying an issue model's - statistics. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([issue_model]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.CalculateIssueModelStatsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if issue_model is not None: - request.issue_model = issue_model - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.calculate_issue_model_stats, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("issue_model", request.issue_model), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_phrase_matcher(self, - request: Optional[Union[contact_center_insights.CreatePhraseMatcherRequest, dict]] = None, - *, - parent: Optional[str] = None, - phrase_matcher: Optional[resources.PhraseMatcher] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.PhraseMatcher: - r"""Creates a phrase matcher. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_create_phrase_matcher(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - phrase_matcher = contact_center_insights_v1.PhraseMatcher() - phrase_matcher.type_ = "ANY_OF" - - request = contact_center_insights_v1.CreatePhraseMatcherRequest( - parent="parent_value", - phrase_matcher=phrase_matcher, - ) - - # Make the request - response = await client.create_phrase_matcher(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.CreatePhraseMatcherRequest, dict]]): - The request object. Request to create a phrase matcher. - parent (:class:`str`): - Required. The parent resource of the phrase matcher. - Required. The location to create a phrase matcher for. - Format: - ``projects//locations/`` or - ``projects//locations/`` - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - phrase_matcher (:class:`google.cloud.contact_center_insights_v1.types.PhraseMatcher`): - Required. The phrase matcher resource - to create. - - This corresponds to the ``phrase_matcher`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.PhraseMatcher: - The phrase matcher resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, phrase_matcher]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.CreatePhraseMatcherRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if phrase_matcher is not None: - request.phrase_matcher = phrase_matcher - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.create_phrase_matcher, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_phrase_matcher(self, - request: Optional[Union[contact_center_insights.GetPhraseMatcherRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.PhraseMatcher: - r"""Gets a phrase matcher. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_get_phrase_matcher(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetPhraseMatcherRequest( - name="name_value", - ) - - # Make the request - response = await client.get_phrase_matcher(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetPhraseMatcherRequest, dict]]): - The request object. The request to get a a phrase - matcher. - name (:class:`str`): - Required. The name of the phrase - matcher to get. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.PhraseMatcher: - The phrase matcher resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.GetPhraseMatcherRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.get_phrase_matcher, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_phrase_matchers(self, - request: Optional[Union[contact_center_insights.ListPhraseMatchersRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListPhraseMatchersAsyncPager: - r"""Lists phrase matchers. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_list_phrase_matchers(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListPhraseMatchersRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_phrase_matchers(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.ListPhraseMatchersRequest, dict]]): - The request object. Request to list phrase matchers. - parent (:class:`str`): - Required. The parent resource of the - phrase matcher. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListPhraseMatchersAsyncPager: - The response of listing phrase - matchers. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.ListPhraseMatchersRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_phrase_matchers, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListPhraseMatchersAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_phrase_matcher(self, - request: Optional[Union[contact_center_insights.DeletePhraseMatcherRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a phrase matcher. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_delete_phrase_matcher(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeletePhraseMatcherRequest( - name="name_value", - ) - - # Make the request - await client.delete_phrase_matcher(request=request) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeletePhraseMatcherRequest, dict]]): - The request object. The request to delete a phrase - matcher. - name (:class:`str`): - Required. The name of the phrase - matcher to delete. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.DeletePhraseMatcherRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.delete_phrase_matcher, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def update_phrase_matcher(self, - request: Optional[Union[contact_center_insights.UpdatePhraseMatcherRequest, dict]] = None, - *, - phrase_matcher: Optional[resources.PhraseMatcher] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.PhraseMatcher: - r"""Updates a phrase matcher. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_update_phrase_matcher(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - phrase_matcher = contact_center_insights_v1.PhraseMatcher() - phrase_matcher.type_ = "ANY_OF" - - request = contact_center_insights_v1.UpdatePhraseMatcherRequest( - phrase_matcher=phrase_matcher, - ) - - # Make the request - response = await client.update_phrase_matcher(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.UpdatePhraseMatcherRequest, dict]]): - The request object. The request to update a phrase - matcher. - phrase_matcher (:class:`google.cloud.contact_center_insights_v1.types.PhraseMatcher`): - Required. The new values for the - phrase matcher. - - This corresponds to the ``phrase_matcher`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The list of fields to be updated. - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.PhraseMatcher: - The phrase matcher resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([phrase_matcher, update_mask]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.UpdatePhraseMatcherRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if phrase_matcher is not None: - request.phrase_matcher = phrase_matcher - if update_mask is not None: - request.update_mask = update_mask - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.update_phrase_matcher, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("phrase_matcher.name", request.phrase_matcher.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def calculate_stats(self, - request: Optional[Union[contact_center_insights.CalculateStatsRequest, dict]] = None, - *, - location: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> contact_center_insights.CalculateStatsResponse: - r"""Gets conversation statistics. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_calculate_stats(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CalculateStatsRequest( - location="location_value", - ) - - # Make the request - response = await client.calculate_stats(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.CalculateStatsRequest, dict]]): - The request object. The request for calculating - conversation statistics. - location (:class:`str`): - Required. The location of the - conversations. - - This corresponds to the ``location`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.CalculateStatsResponse: - The response for calculating - conversation statistics. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([location]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.CalculateStatsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if location is not None: - request.location = location - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.calculate_stats, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("location", request.location), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_settings(self, - request: Optional[Union[contact_center_insights.GetSettingsRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Settings: - r"""Gets project-level settings. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_get_settings(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetSettingsRequest( - name="name_value", - ) - - # Make the request - response = await client.get_settings(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetSettingsRequest, dict]]): - The request object. The request to get project-level - settings. - name (:class:`str`): - Required. The name of the settings - resource to get. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.Settings: - The settings resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.GetSettingsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.get_settings, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_settings(self, - request: Optional[Union[contact_center_insights.UpdateSettingsRequest, dict]] = None, - *, - settings: Optional[resources.Settings] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Settings: - r"""Updates project-level settings. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_update_settings(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UpdateSettingsRequest( - ) - - # Make the request - response = await client.update_settings(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.UpdateSettingsRequest, dict]]): - The request object. The request to update project-level - settings. - settings (:class:`google.cloud.contact_center_insights_v1.types.Settings`): - Required. The new settings values. - This corresponds to the ``settings`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. The list of fields to be - updated. - - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.Settings: - The settings resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([settings, update_mask]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.UpdateSettingsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if settings is not None: - request.settings = settings - if update_mask is not None: - request.update_mask = update_mask - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.update_settings, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("settings.name", request.settings.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_view(self, - request: Optional[Union[contact_center_insights.CreateViewRequest, dict]] = None, - *, - parent: Optional[str] = None, - view: Optional[resources.View] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.View: - r"""Creates a view. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_create_view(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CreateViewRequest( - parent="parent_value", - ) - - # Make the request - response = await client.create_view(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.CreateViewRequest, dict]]): - The request object. The request to create a view. - parent (:class:`str`): - Required. The parent resource of the view. Required. The - location to create a view for. Format: - ``projects//locations/`` or - ``projects//locations/`` - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - view (:class:`google.cloud.contact_center_insights_v1.types.View`): - Required. The view resource to - create. - - This corresponds to the ``view`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.View: - The View resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, view]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.CreateViewRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if view is not None: - request.view = view - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.create_view, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_view(self, - request: Optional[Union[contact_center_insights.GetViewRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.View: - r"""Gets a view. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_get_view(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetViewRequest( - name="name_value", - ) - - # Make the request - response = await client.get_view(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.GetViewRequest, dict]]): - The request object. The request to get a view. - name (:class:`str`): - Required. The name of the view to - get. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.View: - The View resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.GetViewRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.get_view, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_views(self, - request: Optional[Union[contact_center_insights.ListViewsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListViewsAsyncPager: - r"""Lists views. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_list_views(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListViewsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_views(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.ListViewsRequest, dict]]): - The request object. The request to list views. - parent (:class:`str`): - Required. The parent resource of the - views. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListViewsAsyncPager: - The response of listing views. - - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.ListViewsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_views, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListViewsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_view(self, - request: Optional[Union[contact_center_insights.UpdateViewRequest, dict]] = None, - *, - view: Optional[resources.View] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.View: - r"""Updates a view. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_update_view(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UpdateViewRequest( - ) - - # Make the request - response = await client.update_view(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.UpdateViewRequest, dict]]): - The request object. The request to update a view. - view (:class:`google.cloud.contact_center_insights_v1.types.View`): - Required. The new view. - This corresponds to the ``view`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The list of fields to be updated. - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.View: - The View resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([view, update_mask]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.UpdateViewRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if view is not None: - request.view = view - if update_mask is not None: - request.update_mask = update_mask - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.update_view, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("view.name", request.view.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_view(self, - request: Optional[Union[contact_center_insights.DeleteViewRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a view. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - async def sample_delete_view(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeleteViewRequest( - name="name_value", - ) - - # Make the request - await client.delete_view(request=request) - - Args: - request (Optional[Union[google.cloud.contact_center_insights_v1.types.DeleteViewRequest, dict]]): - The request object. The request to delete a view. - name (:class:`str`): - Required. The name of the view to - delete. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - request = contact_center_insights.DeleteViewRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.delete_view, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def list_operations( - self, - request: Optional[operations_pb2.ListOperationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operations_pb2.ListOperationsResponse: - r"""Lists operations that match the specified filter in the request. - - Args: - request (:class:`~.operations_pb2.ListOperationsRequest`): - The request object. Request message for - `ListOperations` method. - retry (google.api_core.retry.Retry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - Returns: - ~.operations_pb2.ListOperationsResponse: - Response message for ``ListOperations`` method. - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = operations_pb2.ListOperationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._client._transport.list_operations, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("name", request.name),)), - ) - - # Send the request. - response = await rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - async def get_operation( - self, - request: Optional[operations_pb2.GetOperationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operations_pb2.Operation: - r"""Gets the latest state of a long-running operation. - - Args: - request (:class:`~.operations_pb2.GetOperationRequest`): - The request object. Request message for - `GetOperation` method. - retry (google.api_core.retry.Retry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - Returns: - ~.operations_pb2.Operation: - An ``Operation`` object. - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = operations_pb2.GetOperationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._client._transport.get_operation, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("name", request.name),)), - ) - - # Send the request. - response = await rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - async def cancel_operation( - self, - request: Optional[operations_pb2.CancelOperationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Starts asynchronous cancellation on a long-running operation. - - The server makes a best effort to cancel the operation, but success - is not guaranteed. If the server doesn't support this method, it returns - `google.rpc.Code.UNIMPLEMENTED`. - - Args: - request (:class:`~.operations_pb2.CancelOperationRequest`): - The request object. Request message for - `CancelOperation` method. - retry (google.api_core.retry.Retry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - Returns: - None - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = operations_pb2.CancelOperationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._client._transport.cancel_operation, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("name", request.name),)), - ) - - # Send the request. - await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - async def __aenter__(self) -> "ContactCenterInsightsAsyncClient": - return self - - async def __aexit__(self, exc_type, exc, tb): - await self.transport.close() - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "ContactCenterInsightsAsyncClient", -) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py deleted file mode 100644 index fbd921cbf054..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py +++ /dev/null @@ -1,4707 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -from collections import OrderedDict -import os -import re -from typing import Dict, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union, cast - -from google.cloud.contact_center_insights_v1 import gapic_version as package_version - -from google.api_core import client_options as client_options_lib -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.contact_center_insights_v1.services.contact_center_insights import pagers -from google.cloud.contact_center_insights_v1.types import contact_center_insights -from google.cloud.contact_center_insights_v1.types import resources -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import ContactCenterInsightsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import ContactCenterInsightsGrpcTransport -from .transports.grpc_asyncio import ContactCenterInsightsGrpcAsyncIOTransport -from .transports.rest import ContactCenterInsightsRestTransport - - -class ContactCenterInsightsClientMeta(type): - """Metaclass for the ContactCenterInsights client. - - This provides class-level methods for building and retrieving - support objects (e.g. transport) without polluting the client instance - objects. - """ - _transport_registry = OrderedDict() # type: Dict[str, Type[ContactCenterInsightsTransport]] - _transport_registry["grpc"] = ContactCenterInsightsGrpcTransport - _transport_registry["grpc_asyncio"] = ContactCenterInsightsGrpcAsyncIOTransport - _transport_registry["rest"] = ContactCenterInsightsRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[ContactCenterInsightsTransport]: - """Returns an appropriate transport class. - - Args: - label: The name of the desired transport. If none is - provided, then the first transport in the registry is used. - - Returns: - The transport class to use. - """ - # If a specific transport is requested, return that one. - if label: - return cls._transport_registry[label] - - # No transport is requested; return the default (that is, the first one - # in the dictionary). - return next(iter(cls._transport_registry.values())) - - -class ContactCenterInsightsClient(metaclass=ContactCenterInsightsClientMeta): - """An API that lets users analyze and explore their business - conversation data. - """ - - @staticmethod - def _get_default_mtls_endpoint(api_endpoint): - """Converts api endpoint to mTLS endpoint. - - Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to - "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. - Args: - api_endpoint (Optional[str]): the api endpoint to convert. - Returns: - str: converted mTLS api endpoint. - """ - if not api_endpoint: - return api_endpoint - - mtls_endpoint_re = re.compile( - r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" - ) - - m = mtls_endpoint_re.match(api_endpoint) - name, mtls, sandbox, googledomain = m.groups() - if mtls or not googledomain: - return api_endpoint - - if sandbox: - return api_endpoint.replace( - "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" - ) - - return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") - - DEFAULT_ENDPOINT = "contactcenterinsights.googleapis.com" - DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore - DEFAULT_ENDPOINT - ) - - @classmethod - def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials - info. - - Args: - info (dict): The service account private key info. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - ContactCenterInsightsClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_info(info) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - @classmethod - def from_service_account_file(cls, filename: str, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - ContactCenterInsightsClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_file( - filename) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - from_service_account_json = from_service_account_file - - @property - def transport(self) -> ContactCenterInsightsTransport: - """Returns the transport used by the client instance. - - Returns: - ContactCenterInsightsTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def analysis_path(project: str,location: str,conversation: str,analysis: str,) -> str: - """Returns a fully-qualified analysis string.""" - return "projects/{project}/locations/{location}/conversations/{conversation}/analyses/{analysis}".format(project=project, location=location, conversation=conversation, analysis=analysis, ) - - @staticmethod - def parse_analysis_path(path: str) -> Dict[str,str]: - """Parses a analysis path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/conversations/(?P.+?)/analyses/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def conversation_path(project: str,location: str,conversation: str,) -> str: - """Returns a fully-qualified conversation string.""" - return "projects/{project}/locations/{location}/conversations/{conversation}".format(project=project, location=location, conversation=conversation, ) - - @staticmethod - def parse_conversation_path(path: str) -> Dict[str,str]: - """Parses a conversation path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/conversations/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def conversation_profile_path(project: str,location: str,conversation_profile: str,) -> str: - """Returns a fully-qualified conversation_profile string.""" - return "projects/{project}/locations/{location}/conversationProfiles/{conversation_profile}".format(project=project, location=location, conversation_profile=conversation_profile, ) - - @staticmethod - def parse_conversation_profile_path(path: str) -> Dict[str,str]: - """Parses a conversation_profile path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/conversationProfiles/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def issue_path(project: str,location: str,issue_model: str,issue: str,) -> str: - """Returns a fully-qualified issue string.""" - return "projects/{project}/locations/{location}/issueModels/{issue_model}/issues/{issue}".format(project=project, location=location, issue_model=issue_model, issue=issue, ) - - @staticmethod - def parse_issue_path(path: str) -> Dict[str,str]: - """Parses a issue path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/issueModels/(?P.+?)/issues/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def issue_model_path(project: str,location: str,issue_model: str,) -> str: - """Returns a fully-qualified issue_model string.""" - return "projects/{project}/locations/{location}/issueModels/{issue_model}".format(project=project, location=location, issue_model=issue_model, ) - - @staticmethod - def parse_issue_model_path(path: str) -> Dict[str,str]: - """Parses a issue_model path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/issueModels/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def participant_path(project: str,conversation: str,participant: str,) -> str: - """Returns a fully-qualified participant string.""" - return "projects/{project}/conversations/{conversation}/participants/{participant}".format(project=project, conversation=conversation, participant=participant, ) - - @staticmethod - def parse_participant_path(path: str) -> Dict[str,str]: - """Parses a participant path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/conversations/(?P.+?)/participants/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def phrase_matcher_path(project: str,location: str,phrase_matcher: str,) -> str: - """Returns a fully-qualified phrase_matcher string.""" - return "projects/{project}/locations/{location}/phraseMatchers/{phrase_matcher}".format(project=project, location=location, phrase_matcher=phrase_matcher, ) - - @staticmethod - def parse_phrase_matcher_path(path: str) -> Dict[str,str]: - """Parses a phrase_matcher path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/phraseMatchers/(?P.+?)$", path) - 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,location: str,) -> str: - """Returns a fully-qualified settings string.""" - return "projects/{project}/locations/{location}/settings".format(project=project, location=location, ) - - @staticmethod - def parse_settings_path(path: str) -> Dict[str,str]: - """Parses a settings path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/settings$", path) - return m.groupdict() if m else {} - - @staticmethod - def view_path(project: str,location: str,view: str,) -> str: - """Returns a fully-qualified view string.""" - return "projects/{project}/locations/{location}/views/{view}".format(project=project, location=location, view=view, ) - - @staticmethod - def parse_view_path(path: str) -> Dict[str,str]: - """Parses a view path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/views/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_billing_account_path(billing_account: str, ) -> str: - """Returns a fully-qualified billing_account string.""" - return "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - - @staticmethod - def parse_common_billing_account_path(path: str) -> Dict[str,str]: - """Parse a billing_account path into its component segments.""" - m = re.match(r"^billingAccounts/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_folder_path(folder: str, ) -> str: - """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder, ) - - @staticmethod - def parse_common_folder_path(path: str) -> Dict[str,str]: - """Parse a folder path into its component segments.""" - m = re.match(r"^folders/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_organization_path(organization: str, ) -> str: - """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization, ) - - @staticmethod - def parse_common_organization_path(path: str) -> Dict[str,str]: - """Parse a organization path into its component segments.""" - m = re.match(r"^organizations/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_project_path(project: str, ) -> str: - """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project, ) - - @staticmethod - def parse_common_project_path(path: str) -> Dict[str,str]: - """Parse a project path into its component segments.""" - m = re.match(r"^projects/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_location_path(project: str, location: str, ) -> str: - """Returns a fully-qualified location string.""" - return "projects/{project}/locations/{location}".format(project=project, location=location, ) - - @staticmethod - def parse_common_location_path(path: str) -> Dict[str,str]: - """Parse a location path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) - return m.groupdict() if m else {} - - @classmethod - def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[client_options_lib.ClientOptions] = None): - """Return the API endpoint and client cert source for mutual TLS. - - The client cert source is determined in the following order: - (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the - client cert source is None. - (2) if `client_options.client_cert_source` is provided, use the provided one; if the - default client cert source exists, use the default one; otherwise the client cert - source is None. - - The API endpoint is determined in the following order: - (1) if `client_options.api_endpoint` if provided, use the provided one. - (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the - default mTLS endpoint; if the environment variable is "never", use the default API - endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise - use the default API endpoint. - - More details can be found at https://google.aip.dev/auth/4114. - - Args: - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. Only the `api_endpoint` and `client_cert_source` properties may be used - in this method. - - Returns: - Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the - client cert source to use. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If any errors happen. - """ - if client_options is None: - client_options = client_options_lib.ClientOptions() - use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") - use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_client_cert not in ("true", "false"): - raise ValueError("Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`") - if use_mtls_endpoint not in ("auto", "never", "always"): - raise MutualTLSChannelError("Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`") - - # Figure out the client cert source to use. - client_cert_source = None - if use_client_cert == "true": - if client_options.client_cert_source: - client_cert_source = client_options.client_cert_source - elif mtls.has_default_client_cert_source(): - client_cert_source = mtls.default_client_cert_source() - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source): - api_endpoint = cls.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = cls.DEFAULT_ENDPOINT - - return api_endpoint, client_cert_source - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Optional[Union[str, ContactCenterInsightsTransport]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the contact center insights client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, ContactCenterInsightsTransport]): The - transport to use. If set to None, a transport is chosen - automatically. - client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the - client. It won't take effect if a ``transport`` instance is provided. - (1) The ``api_endpoint`` property can be used to override the - default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT - environment variable can also be used to override the endpoint: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto switch to the - default mTLS endpoint if client certificate is present, this is - the default value). However, the ``api_endpoint`` property takes - precedence if provided. - (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide client certificate for mutual TLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - """ - if isinstance(client_options, dict): - client_options = client_options_lib.from_dict(client_options) - if client_options is None: - client_options = client_options_lib.ClientOptions() - client_options = cast(client_options_lib.ClientOptions, client_options) - - api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source(client_options) - - api_key_value = getattr(client_options, "api_key", None) - if api_key_value and credentials: - raise ValueError("client_options.api_key and credentials are mutually exclusive") - - # Save or instantiate the transport. - # Ordinarily, we provide the transport, but allowing a custom transport - # instance provides an extensibility point for unusual situations. - if isinstance(transport, ContactCenterInsightsTransport): - # transport is a ContactCenterInsightsTransport instance. - if credentials or client_options.credentials_file or api_key_value: - raise ValueError("When providing a transport instance, " - "provide its credentials directly.") - if client_options.scopes: - raise ValueError( - "When providing a transport instance, provide its scopes " - "directly." - ) - self._transport = transport - else: - import google.auth._default # type: ignore - - if api_key_value and hasattr(google.auth._default, "get_api_key_credentials"): - credentials = google.auth._default.get_api_key_credentials(api_key_value) - - Transport = type(self).get_transport_class(transport) - self._transport = Transport( - credentials=credentials, - credentials_file=client_options.credentials_file, - host=api_endpoint, - scopes=client_options.scopes, - client_cert_source_for_mtls=client_cert_source_func, - quota_project_id=client_options.quota_project_id, - client_info=client_info, - always_use_jwt_access=True, - api_audience=client_options.api_audience, - ) - - def create_conversation(self, - request: Optional[Union[contact_center_insights.CreateConversationRequest, dict]] = None, - *, - parent: Optional[str] = None, - conversation: Optional[resources.Conversation] = None, - conversation_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Conversation: - r"""Creates a conversation. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_create_conversation(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CreateConversationRequest( - parent="parent_value", - ) - - # Make the request - response = client.create_conversation(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.CreateConversationRequest, dict]): - The request object. Request to create a conversation. - parent (str): - Required. The parent resource of the - conversation. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - conversation (google.cloud.contact_center_insights_v1.types.Conversation): - Required. The conversation resource - to create. - - This corresponds to the ``conversation`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - conversation_id (str): - A unique ID for the new conversation. This ID will - become the final component of the conversation's - resource name. If no ID is specified, a server-generated - ID will be used. - - This value should be 4-64 characters and must match the - regular expression ``^[a-z0-9-]{4,64}$``. Valid - characters are ``[a-z][0-9]-`` - - This corresponds to the ``conversation_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.Conversation: - The conversation resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, conversation, conversation_id]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.CreateConversationRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.CreateConversationRequest): - request = contact_center_insights.CreateConversationRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if conversation is not None: - request.conversation = conversation - if conversation_id is not None: - request.conversation_id = conversation_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_conversation] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def upload_conversation(self, - request: Optional[Union[contact_center_insights.UploadConversationRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Create a longrunning conversation upload operation. - This method differs from CreateConversation by allowing - audio transcription and optional DLP redaction. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_upload_conversation(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UploadConversationRequest( - parent="parent_value", - ) - - # Make the request - operation = client.upload_conversation(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.UploadConversationRequest, dict]): - The request object. Request to upload a conversation. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.contact_center_insights_v1.types.Conversation` - The conversation resource. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.UploadConversationRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.UploadConversationRequest): - request = contact_center_insights.UploadConversationRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.upload_conversation] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - resources.Conversation, - metadata_type=contact_center_insights.UploadConversationMetadata, - ) - - # Done; return the response. - return response - - def update_conversation(self, - request: Optional[Union[contact_center_insights.UpdateConversationRequest, dict]] = None, - *, - conversation: Optional[resources.Conversation] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Conversation: - r"""Updates a conversation. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_update_conversation(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UpdateConversationRequest( - ) - - # Make the request - response = client.update_conversation(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.UpdateConversationRequest, dict]): - The request object. The request to update a conversation. - conversation (google.cloud.contact_center_insights_v1.types.Conversation): - Required. The new values for the - conversation. - - This corresponds to the ``conversation`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The list of fields to be updated. - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.Conversation: - The conversation resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([conversation, update_mask]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.UpdateConversationRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.UpdateConversationRequest): - request = contact_center_insights.UpdateConversationRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if conversation is not None: - request.conversation = conversation - if update_mask is not None: - request.update_mask = update_mask - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.update_conversation] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("conversation.name", request.conversation.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_conversation(self, - request: Optional[Union[contact_center_insights.GetConversationRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Conversation: - r"""Gets a conversation. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_get_conversation(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetConversationRequest( - name="name_value", - ) - - # Make the request - response = client.get_conversation(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.GetConversationRequest, dict]): - The request object. The request to get a conversation. - name (str): - Required. The name of the - conversation to get. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.Conversation: - The conversation resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.GetConversationRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.GetConversationRequest): - request = contact_center_insights.GetConversationRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_conversation] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_conversations(self, - request: Optional[Union[contact_center_insights.ListConversationsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListConversationsPager: - r"""Lists conversations. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_list_conversations(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListConversationsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_conversations(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.ListConversationsRequest, dict]): - The request object. Request to list conversations. - parent (str): - Required. The parent resource of the - conversation. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListConversationsPager: - The response of listing - conversations. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.ListConversationsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.ListConversationsRequest): - request = contact_center_insights.ListConversationsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_conversations] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__iter__` convenience method. - response = pagers.ListConversationsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_conversation(self, - request: Optional[Union[contact_center_insights.DeleteConversationRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a conversation. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_delete_conversation(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeleteConversationRequest( - name="name_value", - ) - - # Make the request - client.delete_conversation(request=request) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.DeleteConversationRequest, dict]): - The request object. The request to delete a conversation. - name (str): - Required. The name of the - conversation to delete. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.DeleteConversationRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.DeleteConversationRequest): - request = contact_center_insights.DeleteConversationRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.delete_conversation] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def create_analysis(self, - request: Optional[Union[contact_center_insights.CreateAnalysisRequest, dict]] = None, - *, - parent: Optional[str] = None, - analysis: Optional[resources.Analysis] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Creates an analysis. The long running operation is - done when the analysis has completed. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_create_analysis(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CreateAnalysisRequest( - parent="parent_value", - ) - - # Make the request - operation = client.create_analysis(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.CreateAnalysisRequest, dict]): - The request object. The request to create an analysis. - parent (str): - Required. The parent resource of the - analysis. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - analysis (google.cloud.contact_center_insights_v1.types.Analysis): - Required. The analysis to create. - This corresponds to the ``analysis`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.contact_center_insights_v1.types.Analysis` - The analysis resource. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, analysis]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.CreateAnalysisRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.CreateAnalysisRequest): - request = contact_center_insights.CreateAnalysisRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if analysis is not None: - request.analysis = analysis - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_analysis] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - resources.Analysis, - metadata_type=contact_center_insights.CreateAnalysisOperationMetadata, - ) - - # Done; return the response. - return response - - def get_analysis(self, - request: Optional[Union[contact_center_insights.GetAnalysisRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Analysis: - r"""Gets an analysis. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_get_analysis(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetAnalysisRequest( - name="name_value", - ) - - # Make the request - response = client.get_analysis(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.GetAnalysisRequest, dict]): - The request object. The request to get an analysis. - name (str): - Required. The name of the analysis to - get. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.Analysis: - The analysis resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.GetAnalysisRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.GetAnalysisRequest): - request = contact_center_insights.GetAnalysisRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_analysis] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_analyses(self, - request: Optional[Union[contact_center_insights.ListAnalysesRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListAnalysesPager: - r"""Lists analyses. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_list_analyses(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListAnalysesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_analyses(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.ListAnalysesRequest, dict]): - The request object. The request to list analyses. - parent (str): - Required. The parent resource of the - analyses. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAnalysesPager: - The response to list analyses. - - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.ListAnalysesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.ListAnalysesRequest): - request = contact_center_insights.ListAnalysesRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_analyses] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__iter__` convenience method. - response = pagers.ListAnalysesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_analysis(self, - request: Optional[Union[contact_center_insights.DeleteAnalysisRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes an analysis. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_delete_analysis(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeleteAnalysisRequest( - name="name_value", - ) - - # Make the request - client.delete_analysis(request=request) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.DeleteAnalysisRequest, dict]): - The request object. The request to delete an analysis. - name (str): - Required. The name of the analysis to - delete. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.DeleteAnalysisRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.DeleteAnalysisRequest): - request = contact_center_insights.DeleteAnalysisRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.delete_analysis] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def bulk_analyze_conversations(self, - request: Optional[Union[contact_center_insights.BulkAnalyzeConversationsRequest, dict]] = None, - *, - parent: Optional[str] = None, - filter: Optional[str] = None, - analysis_percentage: Optional[float] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Analyzes multiple conversations in a single request. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_bulk_analyze_conversations(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.BulkAnalyzeConversationsRequest( - parent="parent_value", - filter="filter_value", - analysis_percentage=0.20170000000000002, - ) - - # Make the request - operation = client.bulk_analyze_conversations(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.BulkAnalyzeConversationsRequest, dict]): - The request object. The request to analyze conversations - in bulk. - parent (str): - Required. The parent resource to - create analyses in. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - filter (str): - Required. Filter used to select the - subset of conversations to analyze. - - This corresponds to the ``filter`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - analysis_percentage (float): - Required. Percentage of selected conversation to - analyze, between [0, 100]. - - This corresponds to the ``analysis_percentage`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.contact_center_insights_v1.types.BulkAnalyzeConversationsResponse` - The response for a bulk analyze conversations operation. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, filter, analysis_percentage]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.BulkAnalyzeConversationsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.BulkAnalyzeConversationsRequest): - request = contact_center_insights.BulkAnalyzeConversationsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if filter is not None: - request.filter = filter - if analysis_percentage is not None: - request.analysis_percentage = analysis_percentage - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.bulk_analyze_conversations] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - contact_center_insights.BulkAnalyzeConversationsResponse, - metadata_type=contact_center_insights.BulkAnalyzeConversationsMetadata, - ) - - # Done; return the response. - return response - - def ingest_conversations(self, - request: Optional[Union[contact_center_insights.IngestConversationsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Imports conversations and processes them according to - the user's configuration. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_ingest_conversations(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - gcs_source = contact_center_insights_v1.GcsSource() - gcs_source.bucket_uri = "bucket_uri_value" - - transcript_object_config = contact_center_insights_v1.TranscriptObjectConfig() - transcript_object_config.medium = "CHAT" - - request = contact_center_insights_v1.IngestConversationsRequest( - gcs_source=gcs_source, - transcript_object_config=transcript_object_config, - parent="parent_value", - ) - - # Make the request - operation = client.ingest_conversations(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.IngestConversationsRequest, dict]): - The request object. The request to ingest conversations. - parent (str): - Required. The parent resource for new - conversations. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.contact_center_insights_v1.types.IngestConversationsResponse` - The response to an IngestConversations operation. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.IngestConversationsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.IngestConversationsRequest): - request = contact_center_insights.IngestConversationsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.ingest_conversations] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - contact_center_insights.IngestConversationsResponse, - metadata_type=contact_center_insights.IngestConversationsMetadata, - ) - - # Done; return the response. - return response - - def export_insights_data(self, - request: Optional[Union[contact_center_insights.ExportInsightsDataRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Export insights data to a destination defined in the - request body. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_export_insights_data(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - big_query_destination = contact_center_insights_v1.BigQueryDestination() - big_query_destination.dataset = "dataset_value" - - request = contact_center_insights_v1.ExportInsightsDataRequest( - big_query_destination=big_query_destination, - parent="parent_value", - ) - - # Make the request - operation = client.export_insights_data(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest, dict]): - The request object. The request to export insights. - parent (str): - Required. The parent resource to - export data from. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.contact_center_insights_v1.types.ExportInsightsDataResponse` - Response for an export insights operation. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.ExportInsightsDataRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.ExportInsightsDataRequest): - request = contact_center_insights.ExportInsightsDataRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.export_insights_data] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - contact_center_insights.ExportInsightsDataResponse, - metadata_type=contact_center_insights.ExportInsightsDataMetadata, - ) - - # Done; return the response. - return response - - def create_issue_model(self, - request: Optional[Union[contact_center_insights.CreateIssueModelRequest, dict]] = None, - *, - parent: Optional[str] = None, - issue_model: Optional[resources.IssueModel] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Creates an issue model. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_create_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CreateIssueModelRequest( - parent="parent_value", - ) - - # Make the request - operation = client.create_issue_model(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.CreateIssueModelRequest, dict]): - The request object. The request to create an issue model. - parent (str): - Required. The parent resource of the - issue model. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - issue_model (google.cloud.contact_center_insights_v1.types.IssueModel): - Required. The issue model to create. - This corresponds to the ``issue_model`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.contact_center_insights_v1.types.IssueModel` - The issue model resource. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, issue_model]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.CreateIssueModelRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.CreateIssueModelRequest): - request = contact_center_insights.CreateIssueModelRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if issue_model is not None: - request.issue_model = issue_model - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_issue_model] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - resources.IssueModel, - metadata_type=contact_center_insights.CreateIssueModelMetadata, - ) - - # Done; return the response. - return response - - def update_issue_model(self, - request: Optional[Union[contact_center_insights.UpdateIssueModelRequest, dict]] = None, - *, - issue_model: Optional[resources.IssueModel] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.IssueModel: - r"""Updates an issue model. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_update_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UpdateIssueModelRequest( - ) - - # Make the request - response = client.update_issue_model(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.UpdateIssueModelRequest, dict]): - The request object. The request to update an issue model. - issue_model (google.cloud.contact_center_insights_v1.types.IssueModel): - Required. The new values for the - issue model. - - This corresponds to the ``issue_model`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The list of fields to be updated. - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.IssueModel: - The issue model resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([issue_model, update_mask]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.UpdateIssueModelRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.UpdateIssueModelRequest): - request = contact_center_insights.UpdateIssueModelRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if issue_model is not None: - request.issue_model = issue_model - if update_mask is not None: - request.update_mask = update_mask - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.update_issue_model] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("issue_model.name", request.issue_model.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_issue_model(self, - request: Optional[Union[contact_center_insights.GetIssueModelRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.IssueModel: - r"""Gets an issue model. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_get_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetIssueModelRequest( - name="name_value", - ) - - # Make the request - response = client.get_issue_model(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.GetIssueModelRequest, dict]): - The request object. The request to get an issue model. - name (str): - Required. The name of the issue model - to get. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.IssueModel: - The issue model resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.GetIssueModelRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.GetIssueModelRequest): - request = contact_center_insights.GetIssueModelRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_issue_model] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_issue_models(self, - request: Optional[Union[contact_center_insights.ListIssueModelsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> contact_center_insights.ListIssueModelsResponse: - r"""Lists issue models. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_list_issue_models(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListIssueModelsRequest( - parent="parent_value", - ) - - # Make the request - response = client.list_issue_models(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.ListIssueModelsRequest, dict]): - The request object. Request to list issue models. - parent (str): - Required. The parent resource of the - issue model. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.ListIssueModelsResponse: - The response of listing issue models. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.ListIssueModelsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.ListIssueModelsRequest): - request = contact_center_insights.ListIssueModelsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_issue_models] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_issue_model(self, - request: Optional[Union[contact_center_insights.DeleteIssueModelRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Deletes an issue model. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_delete_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeleteIssueModelRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_issue_model(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.DeleteIssueModelRequest, dict]): - The request object. The request to delete an issue model. - name (str): - Required. The name of the issue model - to delete. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.DeleteIssueModelRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.DeleteIssueModelRequest): - request = contact_center_insights.DeleteIssueModelRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.delete_issue_model] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - empty_pb2.Empty, - metadata_type=contact_center_insights.DeleteIssueModelMetadata, - ) - - # Done; return the response. - return response - - def deploy_issue_model(self, - request: Optional[Union[contact_center_insights.DeployIssueModelRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Deploys an issue model. Returns an error if a model - is already deployed. An issue model can only be used in - analysis after it has been deployed. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_deploy_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeployIssueModelRequest( - name="name_value", - ) - - # Make the request - operation = client.deploy_issue_model(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.DeployIssueModelRequest, dict]): - The request object. The request to deploy an issue model. - name (str): - Required. The issue model to deploy. - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.contact_center_insights_v1.types.DeployIssueModelResponse` - The response to deploy an issue model. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.DeployIssueModelRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.DeployIssueModelRequest): - request = contact_center_insights.DeployIssueModelRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.deploy_issue_model] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - contact_center_insights.DeployIssueModelResponse, - metadata_type=contact_center_insights.DeployIssueModelMetadata, - ) - - # Done; return the response. - return response - - def undeploy_issue_model(self, - request: Optional[Union[contact_center_insights.UndeployIssueModelRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Undeploys an issue model. - An issue model can not be used in analysis after it has - been undeployed. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_undeploy_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UndeployIssueModelRequest( - name="name_value", - ) - - # Make the request - operation = client.undeploy_issue_model(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.UndeployIssueModelRequest, dict]): - The request object. The request to undeploy an issue - model. - name (str): - Required. The issue model to - undeploy. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.contact_center_insights_v1.types.UndeployIssueModelResponse` - The response to undeploy an issue model. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.UndeployIssueModelRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.UndeployIssueModelRequest): - request = contact_center_insights.UndeployIssueModelRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.undeploy_issue_model] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - contact_center_insights.UndeployIssueModelResponse, - metadata_type=contact_center_insights.UndeployIssueModelMetadata, - ) - - # Done; return the response. - return response - - def get_issue(self, - request: Optional[Union[contact_center_insights.GetIssueRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Issue: - r"""Gets an issue. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_get_issue(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetIssueRequest( - name="name_value", - ) - - # Make the request - response = client.get_issue(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.GetIssueRequest, dict]): - The request object. The request to get an issue. - name (str): - Required. The name of the issue to - get. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.Issue: - The issue resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.GetIssueRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.GetIssueRequest): - request = contact_center_insights.GetIssueRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_issue] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_issues(self, - request: Optional[Union[contact_center_insights.ListIssuesRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> contact_center_insights.ListIssuesResponse: - r"""Lists issues. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_list_issues(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListIssuesRequest( - parent="parent_value", - ) - - # Make the request - response = client.list_issues(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.ListIssuesRequest, dict]): - The request object. Request to list issues. - parent (str): - Required. The parent resource of the - issue. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.ListIssuesResponse: - The response of listing issues. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.ListIssuesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.ListIssuesRequest): - request = contact_center_insights.ListIssuesRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_issues] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_issue(self, - request: Optional[Union[contact_center_insights.UpdateIssueRequest, dict]] = None, - *, - issue: Optional[resources.Issue] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Issue: - r"""Updates an issue. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_update_issue(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UpdateIssueRequest( - ) - - # Make the request - response = client.update_issue(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.UpdateIssueRequest, dict]): - The request object. The request to update an issue. - issue (google.cloud.contact_center_insights_v1.types.Issue): - Required. The new values for the - issue. - - This corresponds to the ``issue`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The list of fields to be updated. - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.Issue: - The issue resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([issue, update_mask]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.UpdateIssueRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.UpdateIssueRequest): - request = contact_center_insights.UpdateIssueRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if issue is not None: - request.issue = issue - if update_mask is not None: - request.update_mask = update_mask - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.update_issue] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("issue.name", request.issue.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_issue(self, - request: Optional[Union[contact_center_insights.DeleteIssueRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes an issue. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_delete_issue(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeleteIssueRequest( - name="name_value", - ) - - # Make the request - client.delete_issue(request=request) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.DeleteIssueRequest, dict]): - The request object. The request to delete an issue. - name (str): - Required. The name of the issue to - delete. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.DeleteIssueRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.DeleteIssueRequest): - request = contact_center_insights.DeleteIssueRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.delete_issue] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def calculate_issue_model_stats(self, - request: Optional[Union[contact_center_insights.CalculateIssueModelStatsRequest, dict]] = None, - *, - issue_model: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> contact_center_insights.CalculateIssueModelStatsResponse: - r"""Gets an issue model's statistics. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_calculate_issue_model_stats(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CalculateIssueModelStatsRequest( - issue_model="issue_model_value", - ) - - # Make the request - response = client.calculate_issue_model_stats(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsRequest, dict]): - The request object. Request to get statistics of an issue - model. - issue_model (str): - Required. The resource name of the - issue model to query against. - - This corresponds to the ``issue_model`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsResponse: - Response of querying an issue model's - statistics. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([issue_model]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.CalculateIssueModelStatsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.CalculateIssueModelStatsRequest): - request = contact_center_insights.CalculateIssueModelStatsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if issue_model is not None: - request.issue_model = issue_model - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.calculate_issue_model_stats] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("issue_model", request.issue_model), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_phrase_matcher(self, - request: Optional[Union[contact_center_insights.CreatePhraseMatcherRequest, dict]] = None, - *, - parent: Optional[str] = None, - phrase_matcher: Optional[resources.PhraseMatcher] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.PhraseMatcher: - r"""Creates a phrase matcher. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_create_phrase_matcher(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - phrase_matcher = contact_center_insights_v1.PhraseMatcher() - phrase_matcher.type_ = "ANY_OF" - - request = contact_center_insights_v1.CreatePhraseMatcherRequest( - parent="parent_value", - phrase_matcher=phrase_matcher, - ) - - # Make the request - response = client.create_phrase_matcher(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.CreatePhraseMatcherRequest, dict]): - The request object. Request to create a phrase matcher. - parent (str): - Required. The parent resource of the phrase matcher. - Required. The location to create a phrase matcher for. - Format: - ``projects//locations/`` or - ``projects//locations/`` - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - phrase_matcher (google.cloud.contact_center_insights_v1.types.PhraseMatcher): - Required. The phrase matcher resource - to create. - - This corresponds to the ``phrase_matcher`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.PhraseMatcher: - The phrase matcher resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, phrase_matcher]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.CreatePhraseMatcherRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.CreatePhraseMatcherRequest): - request = contact_center_insights.CreatePhraseMatcherRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if phrase_matcher is not None: - request.phrase_matcher = phrase_matcher - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_phrase_matcher] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_phrase_matcher(self, - request: Optional[Union[contact_center_insights.GetPhraseMatcherRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.PhraseMatcher: - r"""Gets a phrase matcher. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_get_phrase_matcher(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetPhraseMatcherRequest( - name="name_value", - ) - - # Make the request - response = client.get_phrase_matcher(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.GetPhraseMatcherRequest, dict]): - The request object. The request to get a a phrase - matcher. - name (str): - Required. The name of the phrase - matcher to get. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.PhraseMatcher: - The phrase matcher resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.GetPhraseMatcherRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.GetPhraseMatcherRequest): - request = contact_center_insights.GetPhraseMatcherRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_phrase_matcher] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_phrase_matchers(self, - request: Optional[Union[contact_center_insights.ListPhraseMatchersRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListPhraseMatchersPager: - r"""Lists phrase matchers. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_list_phrase_matchers(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListPhraseMatchersRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_phrase_matchers(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.ListPhraseMatchersRequest, dict]): - The request object. Request to list phrase matchers. - parent (str): - Required. The parent resource of the - phrase matcher. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListPhraseMatchersPager: - The response of listing phrase - matchers. - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.ListPhraseMatchersRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.ListPhraseMatchersRequest): - request = contact_center_insights.ListPhraseMatchersRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_phrase_matchers] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__iter__` convenience method. - response = pagers.ListPhraseMatchersPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_phrase_matcher(self, - request: Optional[Union[contact_center_insights.DeletePhraseMatcherRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a phrase matcher. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_delete_phrase_matcher(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeletePhraseMatcherRequest( - name="name_value", - ) - - # Make the request - client.delete_phrase_matcher(request=request) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.DeletePhraseMatcherRequest, dict]): - The request object. The request to delete a phrase - matcher. - name (str): - Required. The name of the phrase - matcher to delete. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.DeletePhraseMatcherRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.DeletePhraseMatcherRequest): - request = contact_center_insights.DeletePhraseMatcherRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.delete_phrase_matcher] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def update_phrase_matcher(self, - request: Optional[Union[contact_center_insights.UpdatePhraseMatcherRequest, dict]] = None, - *, - phrase_matcher: Optional[resources.PhraseMatcher] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.PhraseMatcher: - r"""Updates a phrase matcher. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_update_phrase_matcher(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - phrase_matcher = contact_center_insights_v1.PhraseMatcher() - phrase_matcher.type_ = "ANY_OF" - - request = contact_center_insights_v1.UpdatePhraseMatcherRequest( - phrase_matcher=phrase_matcher, - ) - - # Make the request - response = client.update_phrase_matcher(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.UpdatePhraseMatcherRequest, dict]): - The request object. The request to update a phrase - matcher. - phrase_matcher (google.cloud.contact_center_insights_v1.types.PhraseMatcher): - Required. The new values for the - phrase matcher. - - This corresponds to the ``phrase_matcher`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The list of fields to be updated. - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.PhraseMatcher: - The phrase matcher resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([phrase_matcher, update_mask]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.UpdatePhraseMatcherRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.UpdatePhraseMatcherRequest): - request = contact_center_insights.UpdatePhraseMatcherRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if phrase_matcher is not None: - request.phrase_matcher = phrase_matcher - if update_mask is not None: - request.update_mask = update_mask - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.update_phrase_matcher] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("phrase_matcher.name", request.phrase_matcher.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def calculate_stats(self, - request: Optional[Union[contact_center_insights.CalculateStatsRequest, dict]] = None, - *, - location: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> contact_center_insights.CalculateStatsResponse: - r"""Gets conversation statistics. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_calculate_stats(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CalculateStatsRequest( - location="location_value", - ) - - # Make the request - response = client.calculate_stats(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.CalculateStatsRequest, dict]): - The request object. The request for calculating - conversation statistics. - location (str): - Required. The location of the - conversations. - - This corresponds to the ``location`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.CalculateStatsResponse: - The response for calculating - conversation statistics. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([location]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.CalculateStatsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.CalculateStatsRequest): - request = contact_center_insights.CalculateStatsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if location is not None: - request.location = location - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.calculate_stats] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("location", request.location), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_settings(self, - request: Optional[Union[contact_center_insights.GetSettingsRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Settings: - r"""Gets project-level settings. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_get_settings(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetSettingsRequest( - name="name_value", - ) - - # Make the request - response = client.get_settings(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.GetSettingsRequest, dict]): - The request object. The request to get project-level - settings. - name (str): - Required. The name of the settings - resource to get. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.Settings: - The settings resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.GetSettingsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.GetSettingsRequest): - request = contact_center_insights.GetSettingsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_settings] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_settings(self, - request: Optional[Union[contact_center_insights.UpdateSettingsRequest, dict]] = None, - *, - settings: Optional[resources.Settings] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.Settings: - r"""Updates project-level settings. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_update_settings(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UpdateSettingsRequest( - ) - - # Make the request - response = client.update_settings(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.UpdateSettingsRequest, dict]): - The request object. The request to update project-level - settings. - settings (google.cloud.contact_center_insights_v1.types.Settings): - Required. The new settings values. - This corresponds to the ``settings`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The list of fields to be - updated. - - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.Settings: - The settings resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([settings, update_mask]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.UpdateSettingsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.UpdateSettingsRequest): - request = contact_center_insights.UpdateSettingsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if settings is not None: - request.settings = settings - if update_mask is not None: - request.update_mask = update_mask - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.update_settings] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("settings.name", request.settings.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_view(self, - request: Optional[Union[contact_center_insights.CreateViewRequest, dict]] = None, - *, - parent: Optional[str] = None, - view: Optional[resources.View] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.View: - r"""Creates a view. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_create_view(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CreateViewRequest( - parent="parent_value", - ) - - # Make the request - response = client.create_view(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.CreateViewRequest, dict]): - The request object. The request to create a view. - parent (str): - Required. The parent resource of the view. Required. The - location to create a view for. Format: - ``projects//locations/`` or - ``projects//locations/`` - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - view (google.cloud.contact_center_insights_v1.types.View): - Required. The view resource to - create. - - This corresponds to the ``view`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.View: - The View resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent, view]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.CreateViewRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.CreateViewRequest): - request = contact_center_insights.CreateViewRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if view is not None: - request.view = view - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_view] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_view(self, - request: Optional[Union[contact_center_insights.GetViewRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.View: - r"""Gets a view. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_get_view(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetViewRequest( - name="name_value", - ) - - # Make the request - response = client.get_view(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.GetViewRequest, dict]): - The request object. The request to get a view. - name (str): - Required. The name of the view to - get. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.View: - The View resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.GetViewRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.GetViewRequest): - request = contact_center_insights.GetViewRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_view] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_views(self, - request: Optional[Union[contact_center_insights.ListViewsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListViewsPager: - r"""Lists views. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_list_views(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListViewsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_views(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.ListViewsRequest, dict]): - The request object. The request to list views. - parent (str): - Required. The parent resource of the - views. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListViewsPager: - The response of listing views. - - Iterating over this object will yield - results and resolve additional pages - automatically. - - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([parent]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.ListViewsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.ListViewsRequest): - request = contact_center_insights.ListViewsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_views] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("parent", request.parent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__iter__` convenience method. - response = pagers.ListViewsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_view(self, - request: Optional[Union[contact_center_insights.UpdateViewRequest, dict]] = None, - *, - view: Optional[resources.View] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> resources.View: - r"""Updates a view. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_update_view(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UpdateViewRequest( - ) - - # Make the request - response = client.update_view(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.UpdateViewRequest, dict]): - The request object. The request to update a view. - view (google.cloud.contact_center_insights_v1.types.View): - Required. The new view. - This corresponds to the ``view`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The list of fields to be updated. - This corresponds to the ``update_mask`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.contact_center_insights_v1.types.View: - The View resource. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([view, update_mask]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.UpdateViewRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.UpdateViewRequest): - request = contact_center_insights.UpdateViewRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if view is not None: - request.view = view - if update_mask is not None: - request.update_mask = update_mask - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.update_view] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("view.name", request.view.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_view(self, - request: Optional[Union[contact_center_insights.DeleteViewRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Deletes a view. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud import contact_center_insights_v1 - - def sample_delete_view(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeleteViewRequest( - name="name_value", - ) - - # Make the request - client.delete_view(request=request) - - Args: - request (Union[google.cloud.contact_center_insights_v1.types.DeleteViewRequest, dict]): - The request object. The request to delete a view. - name (str): - Required. The name of the view to - delete. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - # Create or coerce a protobuf request object. - # Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - has_flattened_params = any([name]) - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # Minor optimization to avoid making a copy if the user passes - # in a contact_center_insights.DeleteViewRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, contact_center_insights.DeleteViewRequest): - request = contact_center_insights.DeleteViewRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.delete_view] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Send the request. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def __enter__(self) -> "ContactCenterInsightsClient": - return self - - def __exit__(self, type, value, traceback): - """Releases underlying transport's resources. - - .. warning:: - ONLY use as a context manager if the transport is NOT shared - with other clients! Exiting the with block will CLOSE the transport - and may cause errors in other clients! - """ - self.transport.close() - - def list_operations( - self, - request: Optional[operations_pb2.ListOperationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operations_pb2.ListOperationsResponse: - r"""Lists operations that match the specified filter in the request. - - Args: - request (:class:`~.operations_pb2.ListOperationsRequest`): - The request object. Request message for - `ListOperations` method. - retry (google.api_core.retry.Retry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - Returns: - ~.operations_pb2.ListOperationsResponse: - Response message for ``ListOperations`` method. - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = operations_pb2.ListOperationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.list_operations, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("name", request.name),)), - ) - - # Send the request. - response = rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - def get_operation( - self, - request: Optional[operations_pb2.GetOperationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operations_pb2.Operation: - r"""Gets the latest state of a long-running operation. - - Args: - request (:class:`~.operations_pb2.GetOperationRequest`): - The request object. Request message for - `GetOperation` method. - retry (google.api_core.retry.Retry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - Returns: - ~.operations_pb2.Operation: - An ``Operation`` object. - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = operations_pb2.GetOperationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.get_operation, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("name", request.name),)), - ) - - # Send the request. - response = rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - def cancel_operation( - self, - request: Optional[operations_pb2.CancelOperationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> None: - r"""Starts asynchronous cancellation on a long-running operation. - - The server makes a best effort to cancel the operation, but success - is not guaranteed. If the server doesn't support this method, it returns - `google.rpc.Code.UNIMPLEMENTED`. - - Args: - request (:class:`~.operations_pb2.CancelOperationRequest`): - The request object. Request message for - `CancelOperation` method. - retry (google.api_core.retry.Retry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - Returns: - None - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = operations_pb2.CancelOperationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.cancel_operation, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("name", request.name),)), - ) - - # Send the request. - rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - - - - - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "ContactCenterInsightsClient", -) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/pagers.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/pagers.py deleted file mode 100644 index d72bcf95cbe6..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/pagers.py +++ /dev/null @@ -1,503 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -from typing import Any, AsyncIterator, Awaitable, Callable, Sequence, Tuple, Optional, Iterator - -from google.cloud.contact_center_insights_v1.types import contact_center_insights -from google.cloud.contact_center_insights_v1.types import resources - - -class ListConversationsPager: - """A pager for iterating through ``list_conversations`` requests. - - This class thinly wraps an initial - :class:`google.cloud.contact_center_insights_v1.types.ListConversationsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``conversations`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListConversations`` requests and continue to iterate - through the ``conversations`` field on the - corresponding responses. - - All the usual :class:`google.cloud.contact_center_insights_v1.types.ListConversationsResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., contact_center_insights.ListConversationsResponse], - request: contact_center_insights.ListConversationsRequest, - response: contact_center_insights.ListConversationsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.contact_center_insights_v1.types.ListConversationsRequest): - The initial request object. - response (google.cloud.contact_center_insights_v1.types.ListConversationsResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = contact_center_insights.ListConversationsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[contact_center_insights.ListConversationsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[resources.Conversation]: - for page in self.pages: - yield from page.conversations - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListConversationsAsyncPager: - """A pager for iterating through ``list_conversations`` requests. - - This class thinly wraps an initial - :class:`google.cloud.contact_center_insights_v1.types.ListConversationsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``conversations`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListConversations`` requests and continue to iterate - through the ``conversations`` field on the - corresponding responses. - - All the usual :class:`google.cloud.contact_center_insights_v1.types.ListConversationsResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., Awaitable[contact_center_insights.ListConversationsResponse]], - request: contact_center_insights.ListConversationsRequest, - response: contact_center_insights.ListConversationsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.contact_center_insights_v1.types.ListConversationsRequest): - The initial request object. - response (google.cloud.contact_center_insights_v1.types.ListConversationsResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = contact_center_insights.ListConversationsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[contact_center_insights.ListConversationsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[resources.Conversation]: - async def async_generator(): - async for page in self.pages: - for response in page.conversations: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListAnalysesPager: - """A pager for iterating through ``list_analyses`` requests. - - This class thinly wraps an initial - :class:`google.cloud.contact_center_insights_v1.types.ListAnalysesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``analyses`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListAnalyses`` requests and continue to iterate - through the ``analyses`` field on the - corresponding responses. - - All the usual :class:`google.cloud.contact_center_insights_v1.types.ListAnalysesResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., contact_center_insights.ListAnalysesResponse], - request: contact_center_insights.ListAnalysesRequest, - response: contact_center_insights.ListAnalysesResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.contact_center_insights_v1.types.ListAnalysesRequest): - The initial request object. - response (google.cloud.contact_center_insights_v1.types.ListAnalysesResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = contact_center_insights.ListAnalysesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[contact_center_insights.ListAnalysesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[resources.Analysis]: - for page in self.pages: - yield from page.analyses - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListAnalysesAsyncPager: - """A pager for iterating through ``list_analyses`` requests. - - This class thinly wraps an initial - :class:`google.cloud.contact_center_insights_v1.types.ListAnalysesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``analyses`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListAnalyses`` requests and continue to iterate - through the ``analyses`` field on the - corresponding responses. - - All the usual :class:`google.cloud.contact_center_insights_v1.types.ListAnalysesResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., Awaitable[contact_center_insights.ListAnalysesResponse]], - request: contact_center_insights.ListAnalysesRequest, - response: contact_center_insights.ListAnalysesResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.contact_center_insights_v1.types.ListAnalysesRequest): - The initial request object. - response (google.cloud.contact_center_insights_v1.types.ListAnalysesResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = contact_center_insights.ListAnalysesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[contact_center_insights.ListAnalysesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[resources.Analysis]: - async def async_generator(): - async for page in self.pages: - for response in page.analyses: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListPhraseMatchersPager: - """A pager for iterating through ``list_phrase_matchers`` requests. - - This class thinly wraps an initial - :class:`google.cloud.contact_center_insights_v1.types.ListPhraseMatchersResponse` object, and - provides an ``__iter__`` method to iterate through its - ``phrase_matchers`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListPhraseMatchers`` requests and continue to iterate - through the ``phrase_matchers`` field on the - corresponding responses. - - All the usual :class:`google.cloud.contact_center_insights_v1.types.ListPhraseMatchersResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., contact_center_insights.ListPhraseMatchersResponse], - request: contact_center_insights.ListPhraseMatchersRequest, - response: contact_center_insights.ListPhraseMatchersResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.contact_center_insights_v1.types.ListPhraseMatchersRequest): - The initial request object. - response (google.cloud.contact_center_insights_v1.types.ListPhraseMatchersResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = contact_center_insights.ListPhraseMatchersRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[contact_center_insights.ListPhraseMatchersResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[resources.PhraseMatcher]: - for page in self.pages: - yield from page.phrase_matchers - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListPhraseMatchersAsyncPager: - """A pager for iterating through ``list_phrase_matchers`` requests. - - This class thinly wraps an initial - :class:`google.cloud.contact_center_insights_v1.types.ListPhraseMatchersResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``phrase_matchers`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListPhraseMatchers`` requests and continue to iterate - through the ``phrase_matchers`` field on the - corresponding responses. - - All the usual :class:`google.cloud.contact_center_insights_v1.types.ListPhraseMatchersResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., Awaitable[contact_center_insights.ListPhraseMatchersResponse]], - request: contact_center_insights.ListPhraseMatchersRequest, - response: contact_center_insights.ListPhraseMatchersResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.contact_center_insights_v1.types.ListPhraseMatchersRequest): - The initial request object. - response (google.cloud.contact_center_insights_v1.types.ListPhraseMatchersResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = contact_center_insights.ListPhraseMatchersRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[contact_center_insights.ListPhraseMatchersResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[resources.PhraseMatcher]: - async def async_generator(): - async for page in self.pages: - for response in page.phrase_matchers: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListViewsPager: - """A pager for iterating through ``list_views`` requests. - - This class thinly wraps an initial - :class:`google.cloud.contact_center_insights_v1.types.ListViewsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``views`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListViews`` requests and continue to iterate - through the ``views`` field on the - corresponding responses. - - All the usual :class:`google.cloud.contact_center_insights_v1.types.ListViewsResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., contact_center_insights.ListViewsResponse], - request: contact_center_insights.ListViewsRequest, - response: contact_center_insights.ListViewsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.contact_center_insights_v1.types.ListViewsRequest): - The initial request object. - response (google.cloud.contact_center_insights_v1.types.ListViewsResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = contact_center_insights.ListViewsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[contact_center_insights.ListViewsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[resources.View]: - for page in self.pages: - yield from page.views - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListViewsAsyncPager: - """A pager for iterating through ``list_views`` requests. - - This class thinly wraps an initial - :class:`google.cloud.contact_center_insights_v1.types.ListViewsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``views`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListViews`` requests and continue to iterate - through the ``views`` field on the - corresponding responses. - - All the usual :class:`google.cloud.contact_center_insights_v1.types.ListViewsResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - def __init__(self, - method: Callable[..., Awaitable[contact_center_insights.ListViewsResponse]], - request: contact_center_insights.ListViewsRequest, - response: contact_center_insights.ListViewsResponse, - *, - metadata: Sequence[Tuple[str, str]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.contact_center_insights_v1.types.ListViewsRequest): - The initial request object. - response (google.cloud.contact_center_insights_v1.types.ListViewsResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = contact_center_insights.ListViewsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[contact_center_insights.ListViewsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[resources.View]: - async def async_generator(): - async for page in self.pages: - for response in page.views: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/__init__.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/__init__.py deleted file mode 100644 index a8cfa0a8c705..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/__init__.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -from collections import OrderedDict -from typing import Dict, Type - -from .base import ContactCenterInsightsTransport -from .grpc import ContactCenterInsightsGrpcTransport -from .grpc_asyncio import ContactCenterInsightsGrpcAsyncIOTransport -from .rest import ContactCenterInsightsRestTransport -from .rest import ContactCenterInsightsRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[ContactCenterInsightsTransport]] -_transport_registry['grpc'] = ContactCenterInsightsGrpcTransport -_transport_registry['grpc_asyncio'] = ContactCenterInsightsGrpcAsyncIOTransport -_transport_registry['rest'] = ContactCenterInsightsRestTransport - -__all__ = ( - 'ContactCenterInsightsTransport', - 'ContactCenterInsightsGrpcTransport', - 'ContactCenterInsightsGrpcAsyncIOTransport', - 'ContactCenterInsightsRestTransport', - 'ContactCenterInsightsRestInterceptor', -) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py deleted file mode 100644 index 7a1631aa7fec..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py +++ /dev/null @@ -1,702 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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 abc -from typing import Awaitable, Callable, Dict, Optional, Sequence, Union - -from google.cloud.contact_center_insights_v1 import gapic_version as package_version - -import google.auth # type: ignore -import google.api_core -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.api_core import operations_v1 -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.contact_center_insights_v1.types import contact_center_insights -from google.cloud.contact_center_insights_v1.types import resources -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -class ContactCenterInsightsTransport(abc.ABC): - """Abstract transport class for ContactCenterInsights.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - ) - - DEFAULT_HOST: str = 'contactcenterinsights.googleapis.com' - def __init__( - self, *, - host: str = DEFAULT_HOST, - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - api_audience: Optional[str] = None, - **kwargs, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A list of scopes. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - """ - - scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} - - # Save the scopes. - self._scopes = scopes - - # If no credentials are provided, then determine the appropriate - # defaults. - if credentials and credentials_file: - raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") - - if credentials_file is not None: - credentials, _ = google.auth.load_credentials_from_file( - credentials_file, - **scopes_kwargs, - quota_project_id=quota_project_id - ) - elif credentials is None: - credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) - # Don't apply audience if the credentials file passed from user. - if hasattr(credentials, "with_gdch_audience"): - credentials = credentials.with_gdch_audience(api_audience if api_audience else host) - - # If the credentials are service account credentials, then always try to use self signed JWT. - if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): - credentials = credentials.with_always_use_jwt_access(True) - - # Save the credentials. - self._credentials = credentials - - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ':' not in host: - host += ':443' - self._host = host - - def _prep_wrapped_messages(self, client_info): - # Precompute the wrapped methods. - self._wrapped_methods = { - self.create_conversation: gapic_v1.method.wrap_method( - self.create_conversation, - default_timeout=None, - client_info=client_info, - ), - self.upload_conversation: gapic_v1.method.wrap_method( - self.upload_conversation, - default_timeout=None, - client_info=client_info, - ), - self.update_conversation: gapic_v1.method.wrap_method( - self.update_conversation, - default_timeout=None, - client_info=client_info, - ), - self.get_conversation: gapic_v1.method.wrap_method( - self.get_conversation, - default_timeout=None, - client_info=client_info, - ), - self.list_conversations: gapic_v1.method.wrap_method( - self.list_conversations, - default_timeout=None, - client_info=client_info, - ), - self.delete_conversation: gapic_v1.method.wrap_method( - self.delete_conversation, - default_timeout=None, - client_info=client_info, - ), - self.create_analysis: gapic_v1.method.wrap_method( - self.create_analysis, - default_timeout=None, - client_info=client_info, - ), - self.get_analysis: gapic_v1.method.wrap_method( - self.get_analysis, - default_timeout=None, - client_info=client_info, - ), - self.list_analyses: gapic_v1.method.wrap_method( - self.list_analyses, - default_timeout=None, - client_info=client_info, - ), - self.delete_analysis: gapic_v1.method.wrap_method( - self.delete_analysis, - default_timeout=None, - client_info=client_info, - ), - self.bulk_analyze_conversations: gapic_v1.method.wrap_method( - self.bulk_analyze_conversations, - default_timeout=None, - client_info=client_info, - ), - self.ingest_conversations: gapic_v1.method.wrap_method( - self.ingest_conversations, - default_timeout=None, - client_info=client_info, - ), - self.export_insights_data: gapic_v1.method.wrap_method( - self.export_insights_data, - default_timeout=None, - client_info=client_info, - ), - self.create_issue_model: gapic_v1.method.wrap_method( - self.create_issue_model, - default_timeout=None, - client_info=client_info, - ), - self.update_issue_model: gapic_v1.method.wrap_method( - self.update_issue_model, - default_timeout=None, - client_info=client_info, - ), - self.get_issue_model: gapic_v1.method.wrap_method( - self.get_issue_model, - default_timeout=None, - client_info=client_info, - ), - self.list_issue_models: gapic_v1.method.wrap_method( - self.list_issue_models, - default_timeout=None, - client_info=client_info, - ), - self.delete_issue_model: gapic_v1.method.wrap_method( - self.delete_issue_model, - default_timeout=None, - client_info=client_info, - ), - self.deploy_issue_model: gapic_v1.method.wrap_method( - self.deploy_issue_model, - default_timeout=None, - client_info=client_info, - ), - self.undeploy_issue_model: gapic_v1.method.wrap_method( - self.undeploy_issue_model, - default_timeout=None, - client_info=client_info, - ), - self.get_issue: gapic_v1.method.wrap_method( - self.get_issue, - default_timeout=None, - client_info=client_info, - ), - self.list_issues: gapic_v1.method.wrap_method( - self.list_issues, - default_timeout=None, - client_info=client_info, - ), - self.update_issue: gapic_v1.method.wrap_method( - self.update_issue, - default_timeout=None, - client_info=client_info, - ), - self.delete_issue: gapic_v1.method.wrap_method( - self.delete_issue, - default_timeout=None, - client_info=client_info, - ), - self.calculate_issue_model_stats: gapic_v1.method.wrap_method( - self.calculate_issue_model_stats, - default_timeout=None, - client_info=client_info, - ), - self.create_phrase_matcher: gapic_v1.method.wrap_method( - self.create_phrase_matcher, - default_timeout=None, - client_info=client_info, - ), - self.get_phrase_matcher: gapic_v1.method.wrap_method( - self.get_phrase_matcher, - default_timeout=None, - client_info=client_info, - ), - self.list_phrase_matchers: gapic_v1.method.wrap_method( - self.list_phrase_matchers, - default_timeout=None, - client_info=client_info, - ), - self.delete_phrase_matcher: gapic_v1.method.wrap_method( - self.delete_phrase_matcher, - default_timeout=None, - client_info=client_info, - ), - self.update_phrase_matcher: gapic_v1.method.wrap_method( - self.update_phrase_matcher, - default_timeout=None, - client_info=client_info, - ), - self.calculate_stats: gapic_v1.method.wrap_method( - self.calculate_stats, - default_timeout=None, - client_info=client_info, - ), - self.get_settings: gapic_v1.method.wrap_method( - self.get_settings, - default_timeout=None, - client_info=client_info, - ), - self.update_settings: gapic_v1.method.wrap_method( - self.update_settings, - default_timeout=None, - client_info=client_info, - ), - self.create_view: gapic_v1.method.wrap_method( - self.create_view, - default_timeout=None, - client_info=client_info, - ), - self.get_view: gapic_v1.method.wrap_method( - self.get_view, - default_timeout=None, - client_info=client_info, - ), - self.list_views: gapic_v1.method.wrap_method( - self.list_views, - default_timeout=None, - client_info=client_info, - ), - self.update_view: gapic_v1.method.wrap_method( - self.update_view, - default_timeout=None, - client_info=client_info, - ), - self.delete_view: gapic_v1.method.wrap_method( - self.delete_view, - default_timeout=None, - client_info=client_info, - ), - } - - def close(self): - """Closes resources associated with the transport. - - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! - """ - raise NotImplementedError() - - @property - def operations_client(self): - """Return the client designed to process long-running operations.""" - raise NotImplementedError() - - @property - def create_conversation(self) -> Callable[ - [contact_center_insights.CreateConversationRequest], - Union[ - resources.Conversation, - Awaitable[resources.Conversation] - ]]: - raise NotImplementedError() - - @property - def upload_conversation(self) -> Callable[ - [contact_center_insights.UploadConversationRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_conversation(self) -> Callable[ - [contact_center_insights.UpdateConversationRequest], - Union[ - resources.Conversation, - Awaitable[resources.Conversation] - ]]: - raise NotImplementedError() - - @property - def get_conversation(self) -> Callable[ - [contact_center_insights.GetConversationRequest], - Union[ - resources.Conversation, - Awaitable[resources.Conversation] - ]]: - raise NotImplementedError() - - @property - def list_conversations(self) -> Callable[ - [contact_center_insights.ListConversationsRequest], - Union[ - contact_center_insights.ListConversationsResponse, - Awaitable[contact_center_insights.ListConversationsResponse] - ]]: - raise NotImplementedError() - - @property - def delete_conversation(self) -> Callable[ - [contact_center_insights.DeleteConversationRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def create_analysis(self) -> Callable[ - [contact_center_insights.CreateAnalysisRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def get_analysis(self) -> Callable[ - [contact_center_insights.GetAnalysisRequest], - Union[ - resources.Analysis, - Awaitable[resources.Analysis] - ]]: - raise NotImplementedError() - - @property - def list_analyses(self) -> Callable[ - [contact_center_insights.ListAnalysesRequest], - Union[ - contact_center_insights.ListAnalysesResponse, - Awaitable[contact_center_insights.ListAnalysesResponse] - ]]: - raise NotImplementedError() - - @property - def delete_analysis(self) -> Callable[ - [contact_center_insights.DeleteAnalysisRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def bulk_analyze_conversations(self) -> Callable[ - [contact_center_insights.BulkAnalyzeConversationsRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def ingest_conversations(self) -> Callable[ - [contact_center_insights.IngestConversationsRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def export_insights_data(self) -> Callable[ - [contact_center_insights.ExportInsightsDataRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def create_issue_model(self) -> Callable[ - [contact_center_insights.CreateIssueModelRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_issue_model(self) -> Callable[ - [contact_center_insights.UpdateIssueModelRequest], - Union[ - resources.IssueModel, - Awaitable[resources.IssueModel] - ]]: - raise NotImplementedError() - - @property - def get_issue_model(self) -> Callable[ - [contact_center_insights.GetIssueModelRequest], - Union[ - resources.IssueModel, - Awaitable[resources.IssueModel] - ]]: - raise NotImplementedError() - - @property - def list_issue_models(self) -> Callable[ - [contact_center_insights.ListIssueModelsRequest], - Union[ - contact_center_insights.ListIssueModelsResponse, - Awaitable[contact_center_insights.ListIssueModelsResponse] - ]]: - raise NotImplementedError() - - @property - def delete_issue_model(self) -> Callable[ - [contact_center_insights.DeleteIssueModelRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def deploy_issue_model(self) -> Callable[ - [contact_center_insights.DeployIssueModelRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def undeploy_issue_model(self) -> Callable[ - [contact_center_insights.UndeployIssueModelRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def get_issue(self) -> Callable[ - [contact_center_insights.GetIssueRequest], - Union[ - resources.Issue, - Awaitable[resources.Issue] - ]]: - raise NotImplementedError() - - @property - def list_issues(self) -> Callable[ - [contact_center_insights.ListIssuesRequest], - Union[ - contact_center_insights.ListIssuesResponse, - Awaitable[contact_center_insights.ListIssuesResponse] - ]]: - raise NotImplementedError() - - @property - def update_issue(self) -> Callable[ - [contact_center_insights.UpdateIssueRequest], - Union[ - resources.Issue, - Awaitable[resources.Issue] - ]]: - raise NotImplementedError() - - @property - def delete_issue(self) -> Callable[ - [contact_center_insights.DeleteIssueRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def calculate_issue_model_stats(self) -> Callable[ - [contact_center_insights.CalculateIssueModelStatsRequest], - Union[ - contact_center_insights.CalculateIssueModelStatsResponse, - Awaitable[contact_center_insights.CalculateIssueModelStatsResponse] - ]]: - raise NotImplementedError() - - @property - def create_phrase_matcher(self) -> Callable[ - [contact_center_insights.CreatePhraseMatcherRequest], - Union[ - resources.PhraseMatcher, - Awaitable[resources.PhraseMatcher] - ]]: - raise NotImplementedError() - - @property - def get_phrase_matcher(self) -> Callable[ - [contact_center_insights.GetPhraseMatcherRequest], - Union[ - resources.PhraseMatcher, - Awaitable[resources.PhraseMatcher] - ]]: - raise NotImplementedError() - - @property - def list_phrase_matchers(self) -> Callable[ - [contact_center_insights.ListPhraseMatchersRequest], - Union[ - contact_center_insights.ListPhraseMatchersResponse, - Awaitable[contact_center_insights.ListPhraseMatchersResponse] - ]]: - raise NotImplementedError() - - @property - def delete_phrase_matcher(self) -> Callable[ - [contact_center_insights.DeletePhraseMatcherRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def update_phrase_matcher(self) -> Callable[ - [contact_center_insights.UpdatePhraseMatcherRequest], - Union[ - resources.PhraseMatcher, - Awaitable[resources.PhraseMatcher] - ]]: - raise NotImplementedError() - - @property - def calculate_stats(self) -> Callable[ - [contact_center_insights.CalculateStatsRequest], - Union[ - contact_center_insights.CalculateStatsResponse, - Awaitable[contact_center_insights.CalculateStatsResponse] - ]]: - raise NotImplementedError() - - @property - def get_settings(self) -> Callable[ - [contact_center_insights.GetSettingsRequest], - Union[ - resources.Settings, - Awaitable[resources.Settings] - ]]: - raise NotImplementedError() - - @property - def update_settings(self) -> Callable[ - [contact_center_insights.UpdateSettingsRequest], - Union[ - resources.Settings, - Awaitable[resources.Settings] - ]]: - raise NotImplementedError() - - @property - def create_view(self) -> Callable[ - [contact_center_insights.CreateViewRequest], - Union[ - resources.View, - Awaitable[resources.View] - ]]: - raise NotImplementedError() - - @property - def get_view(self) -> Callable[ - [contact_center_insights.GetViewRequest], - Union[ - resources.View, - Awaitable[resources.View] - ]]: - raise NotImplementedError() - - @property - def list_views(self) -> Callable[ - [contact_center_insights.ListViewsRequest], - Union[ - contact_center_insights.ListViewsResponse, - Awaitable[contact_center_insights.ListViewsResponse] - ]]: - raise NotImplementedError() - - @property - def update_view(self) -> Callable[ - [contact_center_insights.UpdateViewRequest], - Union[ - resources.View, - Awaitable[resources.View] - ]]: - raise NotImplementedError() - - @property - def delete_view(self) -> Callable[ - [contact_center_insights.DeleteViewRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def list_operations( - self, - ) -> Callable[ - [operations_pb2.ListOperationsRequest], - Union[operations_pb2.ListOperationsResponse, Awaitable[operations_pb2.ListOperationsResponse]], - ]: - raise NotImplementedError() - - @property - def get_operation( - self, - ) -> Callable[ - [operations_pb2.GetOperationRequest], - Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], - ]: - raise NotImplementedError() - - @property - def cancel_operation( - self, - ) -> Callable[ - [operations_pb2.CancelOperationRequest], - None, - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'ContactCenterInsightsTransport', -) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py deleted file mode 100644 index 252a4273d43e..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py +++ /dev/null @@ -1,1311 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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 warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers -from google.api_core import operations_v1 -from google.api_core import gapic_v1 -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.contact_center_insights_v1.types import contact_center_insights -from google.cloud.contact_center_insights_v1.types import resources -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import ContactCenterInsightsTransport, DEFAULT_CLIENT_INFO - - -class ContactCenterInsightsGrpcTransport(ContactCenterInsightsTransport): - """gRPC backend transport for ContactCenterInsights. - - An API that lets users analyze and explore their business - conversation data. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends protocol buffers over the wire using gRPC (which is built on - top of HTTP/2); the ``grpcio`` package must be installed. - """ - _stubs: Dict[str, Callable] - - def __init__(self, *, - host: str = 'contactcenterinsights.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: Optional[grpc.Channel] = None, - api_mtls_endpoint: Optional[str] = None, - client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, - client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - api_audience: Optional[str] = None, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if ``channel`` is provided. - channel (Optional[grpc.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or application default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for the grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure a mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - self._operations_client: Optional[operations_v1.OperationsClient] = None - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - api_audience=api_audience, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - # use the credentials which are saved - credentials=self._credentials, - # Set ``credentials_file`` to ``None`` here as - # the credentials that we saved earlier should be used. - credentials_file=None, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @classmethod - def create_channel(cls, - host: str = 'contactcenterinsights.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> grpc.Channel: - """Create and return a gRPC channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - grpc.Channel: A gRPC channel object. - - Raises: - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - - return grpc_helpers.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs - ) - - @property - def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ - return self._grpc_channel - - @property - def operations_client(self) -> operations_v1.OperationsClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Quick check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def create_conversation(self) -> Callable[ - [contact_center_insights.CreateConversationRequest], - resources.Conversation]: - r"""Return a callable for the create conversation method over gRPC. - - Creates a conversation. - - Returns: - Callable[[~.CreateConversationRequest], - ~.Conversation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'create_conversation' not in self._stubs: - self._stubs['create_conversation'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateConversation', - request_serializer=contact_center_insights.CreateConversationRequest.serialize, - response_deserializer=resources.Conversation.deserialize, - ) - return self._stubs['create_conversation'] - - @property - def upload_conversation(self) -> Callable[ - [contact_center_insights.UploadConversationRequest], - operations_pb2.Operation]: - r"""Return a callable for the upload conversation method over gRPC. - - Create a longrunning conversation upload operation. - This method differs from CreateConversation by allowing - audio transcription and optional DLP redaction. - - Returns: - Callable[[~.UploadConversationRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'upload_conversation' not in self._stubs: - self._stubs['upload_conversation'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UploadConversation', - request_serializer=contact_center_insights.UploadConversationRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['upload_conversation'] - - @property - def update_conversation(self) -> Callable[ - [contact_center_insights.UpdateConversationRequest], - resources.Conversation]: - r"""Return a callable for the update conversation method over gRPC. - - Updates a conversation. - - Returns: - Callable[[~.UpdateConversationRequest], - ~.Conversation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'update_conversation' not in self._stubs: - self._stubs['update_conversation'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateConversation', - request_serializer=contact_center_insights.UpdateConversationRequest.serialize, - response_deserializer=resources.Conversation.deserialize, - ) - return self._stubs['update_conversation'] - - @property - def get_conversation(self) -> Callable[ - [contact_center_insights.GetConversationRequest], - resources.Conversation]: - r"""Return a callable for the get conversation method over gRPC. - - Gets a conversation. - - Returns: - Callable[[~.GetConversationRequest], - ~.Conversation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'get_conversation' not in self._stubs: - self._stubs['get_conversation'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetConversation', - request_serializer=contact_center_insights.GetConversationRequest.serialize, - response_deserializer=resources.Conversation.deserialize, - ) - return self._stubs['get_conversation'] - - @property - def list_conversations(self) -> Callable[ - [contact_center_insights.ListConversationsRequest], - contact_center_insights.ListConversationsResponse]: - r"""Return a callable for the list conversations method over gRPC. - - Lists conversations. - - Returns: - Callable[[~.ListConversationsRequest], - ~.ListConversationsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'list_conversations' not in self._stubs: - self._stubs['list_conversations'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListConversations', - request_serializer=contact_center_insights.ListConversationsRequest.serialize, - response_deserializer=contact_center_insights.ListConversationsResponse.deserialize, - ) - return self._stubs['list_conversations'] - - @property - def delete_conversation(self) -> Callable[ - [contact_center_insights.DeleteConversationRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete conversation method over gRPC. - - Deletes a conversation. - - Returns: - Callable[[~.DeleteConversationRequest], - ~.Empty]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_conversation' not in self._stubs: - self._stubs['delete_conversation'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteConversation', - request_serializer=contact_center_insights.DeleteConversationRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_conversation'] - - @property - def create_analysis(self) -> Callable[ - [contact_center_insights.CreateAnalysisRequest], - operations_pb2.Operation]: - r"""Return a callable for the create analysis method over gRPC. - - Creates an analysis. The long running operation is - done when the analysis has completed. - - Returns: - Callable[[~.CreateAnalysisRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'create_analysis' not in self._stubs: - self._stubs['create_analysis'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateAnalysis', - request_serializer=contact_center_insights.CreateAnalysisRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_analysis'] - - @property - def get_analysis(self) -> Callable[ - [contact_center_insights.GetAnalysisRequest], - resources.Analysis]: - r"""Return a callable for the get analysis method over gRPC. - - Gets an analysis. - - Returns: - Callable[[~.GetAnalysisRequest], - ~.Analysis]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'get_analysis' not in self._stubs: - self._stubs['get_analysis'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetAnalysis', - request_serializer=contact_center_insights.GetAnalysisRequest.serialize, - response_deserializer=resources.Analysis.deserialize, - ) - return self._stubs['get_analysis'] - - @property - def list_analyses(self) -> Callable[ - [contact_center_insights.ListAnalysesRequest], - contact_center_insights.ListAnalysesResponse]: - r"""Return a callable for the list analyses method over gRPC. - - Lists analyses. - - Returns: - Callable[[~.ListAnalysesRequest], - ~.ListAnalysesResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'list_analyses' not in self._stubs: - self._stubs['list_analyses'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListAnalyses', - request_serializer=contact_center_insights.ListAnalysesRequest.serialize, - response_deserializer=contact_center_insights.ListAnalysesResponse.deserialize, - ) - return self._stubs['list_analyses'] - - @property - def delete_analysis(self) -> Callable[ - [contact_center_insights.DeleteAnalysisRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete analysis method over gRPC. - - Deletes an analysis. - - Returns: - Callable[[~.DeleteAnalysisRequest], - ~.Empty]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_analysis' not in self._stubs: - self._stubs['delete_analysis'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteAnalysis', - request_serializer=contact_center_insights.DeleteAnalysisRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_analysis'] - - @property - def bulk_analyze_conversations(self) -> Callable[ - [contact_center_insights.BulkAnalyzeConversationsRequest], - operations_pb2.Operation]: - r"""Return a callable for the bulk analyze conversations method over gRPC. - - Analyzes multiple conversations in a single request. - - Returns: - Callable[[~.BulkAnalyzeConversationsRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'bulk_analyze_conversations' not in self._stubs: - self._stubs['bulk_analyze_conversations'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/BulkAnalyzeConversations', - request_serializer=contact_center_insights.BulkAnalyzeConversationsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['bulk_analyze_conversations'] - - @property - def ingest_conversations(self) -> Callable[ - [contact_center_insights.IngestConversationsRequest], - operations_pb2.Operation]: - r"""Return a callable for the ingest conversations method over gRPC. - - Imports conversations and processes them according to - the user's configuration. - - Returns: - Callable[[~.IngestConversationsRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'ingest_conversations' not in self._stubs: - self._stubs['ingest_conversations'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/IngestConversations', - request_serializer=contact_center_insights.IngestConversationsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['ingest_conversations'] - - @property - def export_insights_data(self) -> Callable[ - [contact_center_insights.ExportInsightsDataRequest], - operations_pb2.Operation]: - r"""Return a callable for the export insights data method over gRPC. - - Export insights data to a destination defined in the - request body. - - Returns: - Callable[[~.ExportInsightsDataRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'export_insights_data' not in self._stubs: - self._stubs['export_insights_data'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ExportInsightsData', - request_serializer=contact_center_insights.ExportInsightsDataRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['export_insights_data'] - - @property - def create_issue_model(self) -> Callable[ - [contact_center_insights.CreateIssueModelRequest], - operations_pb2.Operation]: - r"""Return a callable for the create issue model method over gRPC. - - Creates an issue model. - - Returns: - Callable[[~.CreateIssueModelRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'create_issue_model' not in self._stubs: - self._stubs['create_issue_model'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateIssueModel', - request_serializer=contact_center_insights.CreateIssueModelRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_issue_model'] - - @property - def update_issue_model(self) -> Callable[ - [contact_center_insights.UpdateIssueModelRequest], - resources.IssueModel]: - r"""Return a callable for the update issue model method over gRPC. - - Updates an issue model. - - Returns: - Callable[[~.UpdateIssueModelRequest], - ~.IssueModel]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'update_issue_model' not in self._stubs: - self._stubs['update_issue_model'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateIssueModel', - request_serializer=contact_center_insights.UpdateIssueModelRequest.serialize, - response_deserializer=resources.IssueModel.deserialize, - ) - return self._stubs['update_issue_model'] - - @property - def get_issue_model(self) -> Callable[ - [contact_center_insights.GetIssueModelRequest], - resources.IssueModel]: - r"""Return a callable for the get issue model method over gRPC. - - Gets an issue model. - - Returns: - Callable[[~.GetIssueModelRequest], - ~.IssueModel]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'get_issue_model' not in self._stubs: - self._stubs['get_issue_model'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetIssueModel', - request_serializer=contact_center_insights.GetIssueModelRequest.serialize, - response_deserializer=resources.IssueModel.deserialize, - ) - return self._stubs['get_issue_model'] - - @property - def list_issue_models(self) -> Callable[ - [contact_center_insights.ListIssueModelsRequest], - contact_center_insights.ListIssueModelsResponse]: - r"""Return a callable for the list issue models method over gRPC. - - Lists issue models. - - Returns: - Callable[[~.ListIssueModelsRequest], - ~.ListIssueModelsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'list_issue_models' not in self._stubs: - self._stubs['list_issue_models'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListIssueModels', - request_serializer=contact_center_insights.ListIssueModelsRequest.serialize, - response_deserializer=contact_center_insights.ListIssueModelsResponse.deserialize, - ) - return self._stubs['list_issue_models'] - - @property - def delete_issue_model(self) -> Callable[ - [contact_center_insights.DeleteIssueModelRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete issue model method over gRPC. - - Deletes an issue model. - - Returns: - Callable[[~.DeleteIssueModelRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_issue_model' not in self._stubs: - self._stubs['delete_issue_model'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteIssueModel', - request_serializer=contact_center_insights.DeleteIssueModelRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_issue_model'] - - @property - def deploy_issue_model(self) -> Callable[ - [contact_center_insights.DeployIssueModelRequest], - operations_pb2.Operation]: - r"""Return a callable for the deploy issue model method over gRPC. - - Deploys an issue model. Returns an error if a model - is already deployed. An issue model can only be used in - analysis after it has been deployed. - - Returns: - Callable[[~.DeployIssueModelRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'deploy_issue_model' not in self._stubs: - self._stubs['deploy_issue_model'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeployIssueModel', - request_serializer=contact_center_insights.DeployIssueModelRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['deploy_issue_model'] - - @property - def undeploy_issue_model(self) -> Callable[ - [contact_center_insights.UndeployIssueModelRequest], - operations_pb2.Operation]: - r"""Return a callable for the undeploy issue model method over gRPC. - - Undeploys an issue model. - An issue model can not be used in analysis after it has - been undeployed. - - Returns: - Callable[[~.UndeployIssueModelRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'undeploy_issue_model' not in self._stubs: - self._stubs['undeploy_issue_model'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UndeployIssueModel', - request_serializer=contact_center_insights.UndeployIssueModelRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['undeploy_issue_model'] - - @property - def get_issue(self) -> Callable[ - [contact_center_insights.GetIssueRequest], - resources.Issue]: - r"""Return a callable for the get issue method over gRPC. - - Gets an issue. - - Returns: - Callable[[~.GetIssueRequest], - ~.Issue]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'get_issue' not in self._stubs: - self._stubs['get_issue'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetIssue', - request_serializer=contact_center_insights.GetIssueRequest.serialize, - response_deserializer=resources.Issue.deserialize, - ) - return self._stubs['get_issue'] - - @property - def list_issues(self) -> Callable[ - [contact_center_insights.ListIssuesRequest], - contact_center_insights.ListIssuesResponse]: - r"""Return a callable for the list issues method over gRPC. - - Lists issues. - - Returns: - Callable[[~.ListIssuesRequest], - ~.ListIssuesResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'list_issues' not in self._stubs: - self._stubs['list_issues'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListIssues', - request_serializer=contact_center_insights.ListIssuesRequest.serialize, - response_deserializer=contact_center_insights.ListIssuesResponse.deserialize, - ) - return self._stubs['list_issues'] - - @property - def update_issue(self) -> Callable[ - [contact_center_insights.UpdateIssueRequest], - resources.Issue]: - r"""Return a callable for the update issue method over gRPC. - - Updates an issue. - - Returns: - Callable[[~.UpdateIssueRequest], - ~.Issue]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'update_issue' not in self._stubs: - self._stubs['update_issue'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateIssue', - request_serializer=contact_center_insights.UpdateIssueRequest.serialize, - response_deserializer=resources.Issue.deserialize, - ) - return self._stubs['update_issue'] - - @property - def delete_issue(self) -> Callable[ - [contact_center_insights.DeleteIssueRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete issue method over gRPC. - - Deletes an issue. - - Returns: - Callable[[~.DeleteIssueRequest], - ~.Empty]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_issue' not in self._stubs: - self._stubs['delete_issue'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteIssue', - request_serializer=contact_center_insights.DeleteIssueRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_issue'] - - @property - def calculate_issue_model_stats(self) -> Callable[ - [contact_center_insights.CalculateIssueModelStatsRequest], - contact_center_insights.CalculateIssueModelStatsResponse]: - r"""Return a callable for the calculate issue model stats method over gRPC. - - Gets an issue model's statistics. - - Returns: - Callable[[~.CalculateIssueModelStatsRequest], - ~.CalculateIssueModelStatsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'calculate_issue_model_stats' not in self._stubs: - self._stubs['calculate_issue_model_stats'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CalculateIssueModelStats', - request_serializer=contact_center_insights.CalculateIssueModelStatsRequest.serialize, - response_deserializer=contact_center_insights.CalculateIssueModelStatsResponse.deserialize, - ) - return self._stubs['calculate_issue_model_stats'] - - @property - def create_phrase_matcher(self) -> Callable[ - [contact_center_insights.CreatePhraseMatcherRequest], - resources.PhraseMatcher]: - r"""Return a callable for the create phrase matcher method over gRPC. - - Creates a phrase matcher. - - Returns: - Callable[[~.CreatePhraseMatcherRequest], - ~.PhraseMatcher]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'create_phrase_matcher' not in self._stubs: - self._stubs['create_phrase_matcher'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreatePhraseMatcher', - request_serializer=contact_center_insights.CreatePhraseMatcherRequest.serialize, - response_deserializer=resources.PhraseMatcher.deserialize, - ) - return self._stubs['create_phrase_matcher'] - - @property - def get_phrase_matcher(self) -> Callable[ - [contact_center_insights.GetPhraseMatcherRequest], - resources.PhraseMatcher]: - r"""Return a callable for the get phrase matcher method over gRPC. - - Gets a phrase matcher. - - Returns: - Callable[[~.GetPhraseMatcherRequest], - ~.PhraseMatcher]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'get_phrase_matcher' not in self._stubs: - self._stubs['get_phrase_matcher'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetPhraseMatcher', - request_serializer=contact_center_insights.GetPhraseMatcherRequest.serialize, - response_deserializer=resources.PhraseMatcher.deserialize, - ) - return self._stubs['get_phrase_matcher'] - - @property - def list_phrase_matchers(self) -> Callable[ - [contact_center_insights.ListPhraseMatchersRequest], - contact_center_insights.ListPhraseMatchersResponse]: - r"""Return a callable for the list phrase matchers method over gRPC. - - Lists phrase matchers. - - Returns: - Callable[[~.ListPhraseMatchersRequest], - ~.ListPhraseMatchersResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'list_phrase_matchers' not in self._stubs: - self._stubs['list_phrase_matchers'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListPhraseMatchers', - request_serializer=contact_center_insights.ListPhraseMatchersRequest.serialize, - response_deserializer=contact_center_insights.ListPhraseMatchersResponse.deserialize, - ) - return self._stubs['list_phrase_matchers'] - - @property - def delete_phrase_matcher(self) -> Callable[ - [contact_center_insights.DeletePhraseMatcherRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete phrase matcher method over gRPC. - - Deletes a phrase matcher. - - Returns: - Callable[[~.DeletePhraseMatcherRequest], - ~.Empty]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_phrase_matcher' not in self._stubs: - self._stubs['delete_phrase_matcher'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeletePhraseMatcher', - request_serializer=contact_center_insights.DeletePhraseMatcherRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_phrase_matcher'] - - @property - def update_phrase_matcher(self) -> Callable[ - [contact_center_insights.UpdatePhraseMatcherRequest], - resources.PhraseMatcher]: - r"""Return a callable for the update phrase matcher method over gRPC. - - Updates a phrase matcher. - - Returns: - Callable[[~.UpdatePhraseMatcherRequest], - ~.PhraseMatcher]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'update_phrase_matcher' not in self._stubs: - self._stubs['update_phrase_matcher'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdatePhraseMatcher', - request_serializer=contact_center_insights.UpdatePhraseMatcherRequest.serialize, - response_deserializer=resources.PhraseMatcher.deserialize, - ) - return self._stubs['update_phrase_matcher'] - - @property - def calculate_stats(self) -> Callable[ - [contact_center_insights.CalculateStatsRequest], - contact_center_insights.CalculateStatsResponse]: - r"""Return a callable for the calculate stats method over gRPC. - - Gets conversation statistics. - - Returns: - Callable[[~.CalculateStatsRequest], - ~.CalculateStatsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'calculate_stats' not in self._stubs: - self._stubs['calculate_stats'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CalculateStats', - request_serializer=contact_center_insights.CalculateStatsRequest.serialize, - response_deserializer=contact_center_insights.CalculateStatsResponse.deserialize, - ) - return self._stubs['calculate_stats'] - - @property - def get_settings(self) -> Callable[ - [contact_center_insights.GetSettingsRequest], - resources.Settings]: - r"""Return a callable for the get settings method over gRPC. - - Gets project-level settings. - - Returns: - Callable[[~.GetSettingsRequest], - ~.Settings]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'get_settings' not in self._stubs: - self._stubs['get_settings'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetSettings', - request_serializer=contact_center_insights.GetSettingsRequest.serialize, - response_deserializer=resources.Settings.deserialize, - ) - return self._stubs['get_settings'] - - @property - def update_settings(self) -> Callable[ - [contact_center_insights.UpdateSettingsRequest], - resources.Settings]: - r"""Return a callable for the update settings method over gRPC. - - Updates project-level settings. - - Returns: - Callable[[~.UpdateSettingsRequest], - ~.Settings]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'update_settings' not in self._stubs: - self._stubs['update_settings'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateSettings', - request_serializer=contact_center_insights.UpdateSettingsRequest.serialize, - response_deserializer=resources.Settings.deserialize, - ) - return self._stubs['update_settings'] - - @property - def create_view(self) -> Callable[ - [contact_center_insights.CreateViewRequest], - resources.View]: - r"""Return a callable for the create view method over gRPC. - - Creates a view. - - Returns: - Callable[[~.CreateViewRequest], - ~.View]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'create_view' not in self._stubs: - self._stubs['create_view'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateView', - request_serializer=contact_center_insights.CreateViewRequest.serialize, - response_deserializer=resources.View.deserialize, - ) - return self._stubs['create_view'] - - @property - def get_view(self) -> Callable[ - [contact_center_insights.GetViewRequest], - resources.View]: - r"""Return a callable for the get view method over gRPC. - - Gets a view. - - Returns: - Callable[[~.GetViewRequest], - ~.View]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'get_view' not in self._stubs: - self._stubs['get_view'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetView', - request_serializer=contact_center_insights.GetViewRequest.serialize, - response_deserializer=resources.View.deserialize, - ) - return self._stubs['get_view'] - - @property - def list_views(self) -> Callable[ - [contact_center_insights.ListViewsRequest], - contact_center_insights.ListViewsResponse]: - r"""Return a callable for the list views method over gRPC. - - Lists views. - - Returns: - Callable[[~.ListViewsRequest], - ~.ListViewsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'list_views' not in self._stubs: - self._stubs['list_views'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListViews', - request_serializer=contact_center_insights.ListViewsRequest.serialize, - response_deserializer=contact_center_insights.ListViewsResponse.deserialize, - ) - return self._stubs['list_views'] - - @property - def update_view(self) -> Callable[ - [contact_center_insights.UpdateViewRequest], - resources.View]: - r"""Return a callable for the update view method over gRPC. - - Updates a view. - - Returns: - Callable[[~.UpdateViewRequest], - ~.View]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'update_view' not in self._stubs: - self._stubs['update_view'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateView', - request_serializer=contact_center_insights.UpdateViewRequest.serialize, - response_deserializer=resources.View.deserialize, - ) - return self._stubs['update_view'] - - @property - def delete_view(self) -> Callable[ - [contact_center_insights.DeleteViewRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete view method over gRPC. - - Deletes a view. - - Returns: - Callable[[~.DeleteViewRequest], - ~.Empty]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_view' not in self._stubs: - self._stubs['delete_view'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteView', - request_serializer=contact_center_insights.DeleteViewRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_view'] - - def close(self): - self.grpc_channel.close() - - @property - def cancel_operation( - self, - ) -> Callable[[operations_pb2.CancelOperationRequest], None]: - r"""Return a callable for the cancel_operation method over gRPC. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( - "/google.longrunning.Operations/CancelOperation", - request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, - response_deserializer=None, - ) - return self._stubs["cancel_operation"] - - @property - def get_operation( - self, - ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: - r"""Return a callable for the get_operation method over gRPC. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( - "/google.longrunning.Operations/GetOperation", - request_serializer=operations_pb2.GetOperationRequest.SerializeToString, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["get_operation"] - - @property - def list_operations( - self, - ) -> Callable[[operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse]: - r"""Return a callable for the list_operations method over gRPC. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( - "/google.longrunning.Operations/ListOperations", - request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, - response_deserializer=operations_pb2.ListOperationsResponse.FromString, - ) - return self._stubs["list_operations"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'ContactCenterInsightsGrpcTransport', -) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py deleted file mode 100644 index a1d6b42a82d1..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py +++ /dev/null @@ -1,1310 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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 warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async -from google.api_core import operations_v1 -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.contact_center_insights_v1.types import contact_center_insights -from google.cloud.contact_center_insights_v1.types import resources -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import ContactCenterInsightsTransport, DEFAULT_CLIENT_INFO -from .grpc import ContactCenterInsightsGrpcTransport - - -class ContactCenterInsightsGrpcAsyncIOTransport(ContactCenterInsightsTransport): - """gRPC AsyncIO backend transport for ContactCenterInsights. - - An API that lets users analyze and explore their business - conversation data. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends protocol buffers over the wire using gRPC (which is built on - top of HTTP/2); the ``grpcio`` package must be installed. - """ - - _grpc_channel: aio.Channel - _stubs: Dict[str, Callable] = {} - - @classmethod - def create_channel(cls, - host: str = 'contactcenterinsights.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> aio.Channel: - """Create and return a gRPC AsyncIO channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - aio.Channel: A gRPC AsyncIO channel object. - """ - - return grpc_helpers_async.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs - ) - - def __init__(self, *, - host: str = 'contactcenterinsights.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: Optional[aio.Channel] = None, - api_mtls_endpoint: Optional[str] = None, - client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, - client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - api_audience: Optional[str] = None, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - channel (Optional[aio.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or application default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for the grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure a mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - api_audience=api_audience, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - # use the credentials which are saved - credentials=self._credentials, - # Set ``credentials_file`` to ``None`` here as - # the credentials that we saved earlier should be used. - credentials_file=None, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @property - def grpc_channel(self) -> aio.Channel: - """Create the channel designed to connect to this service. - - This property caches on the instance; repeated calls return - the same channel. - """ - # Return the channel from cache. - return self._grpc_channel - - @property - def operations_client(self) -> operations_v1.OperationsAsyncClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Quick check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def create_conversation(self) -> Callable[ - [contact_center_insights.CreateConversationRequest], - Awaitable[resources.Conversation]]: - r"""Return a callable for the create conversation method over gRPC. - - Creates a conversation. - - Returns: - Callable[[~.CreateConversationRequest], - Awaitable[~.Conversation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'create_conversation' not in self._stubs: - self._stubs['create_conversation'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateConversation', - request_serializer=contact_center_insights.CreateConversationRequest.serialize, - response_deserializer=resources.Conversation.deserialize, - ) - return self._stubs['create_conversation'] - - @property - def upload_conversation(self) -> Callable[ - [contact_center_insights.UploadConversationRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the upload conversation method over gRPC. - - Create a longrunning conversation upload operation. - This method differs from CreateConversation by allowing - audio transcription and optional DLP redaction. - - Returns: - Callable[[~.UploadConversationRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'upload_conversation' not in self._stubs: - self._stubs['upload_conversation'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UploadConversation', - request_serializer=contact_center_insights.UploadConversationRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['upload_conversation'] - - @property - def update_conversation(self) -> Callable[ - [contact_center_insights.UpdateConversationRequest], - Awaitable[resources.Conversation]]: - r"""Return a callable for the update conversation method over gRPC. - - Updates a conversation. - - Returns: - Callable[[~.UpdateConversationRequest], - Awaitable[~.Conversation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'update_conversation' not in self._stubs: - self._stubs['update_conversation'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateConversation', - request_serializer=contact_center_insights.UpdateConversationRequest.serialize, - response_deserializer=resources.Conversation.deserialize, - ) - return self._stubs['update_conversation'] - - @property - def get_conversation(self) -> Callable[ - [contact_center_insights.GetConversationRequest], - Awaitable[resources.Conversation]]: - r"""Return a callable for the get conversation method over gRPC. - - Gets a conversation. - - Returns: - Callable[[~.GetConversationRequest], - Awaitable[~.Conversation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'get_conversation' not in self._stubs: - self._stubs['get_conversation'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetConversation', - request_serializer=contact_center_insights.GetConversationRequest.serialize, - response_deserializer=resources.Conversation.deserialize, - ) - return self._stubs['get_conversation'] - - @property - def list_conversations(self) -> Callable[ - [contact_center_insights.ListConversationsRequest], - Awaitable[contact_center_insights.ListConversationsResponse]]: - r"""Return a callable for the list conversations method over gRPC. - - Lists conversations. - - Returns: - Callable[[~.ListConversationsRequest], - Awaitable[~.ListConversationsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'list_conversations' not in self._stubs: - self._stubs['list_conversations'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListConversations', - request_serializer=contact_center_insights.ListConversationsRequest.serialize, - response_deserializer=contact_center_insights.ListConversationsResponse.deserialize, - ) - return self._stubs['list_conversations'] - - @property - def delete_conversation(self) -> Callable[ - [contact_center_insights.DeleteConversationRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete conversation method over gRPC. - - Deletes a conversation. - - Returns: - Callable[[~.DeleteConversationRequest], - Awaitable[~.Empty]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_conversation' not in self._stubs: - self._stubs['delete_conversation'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteConversation', - request_serializer=contact_center_insights.DeleteConversationRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_conversation'] - - @property - def create_analysis(self) -> Callable[ - [contact_center_insights.CreateAnalysisRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create analysis method over gRPC. - - Creates an analysis. The long running operation is - done when the analysis has completed. - - Returns: - Callable[[~.CreateAnalysisRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'create_analysis' not in self._stubs: - self._stubs['create_analysis'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateAnalysis', - request_serializer=contact_center_insights.CreateAnalysisRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_analysis'] - - @property - def get_analysis(self) -> Callable[ - [contact_center_insights.GetAnalysisRequest], - Awaitable[resources.Analysis]]: - r"""Return a callable for the get analysis method over gRPC. - - Gets an analysis. - - Returns: - Callable[[~.GetAnalysisRequest], - Awaitable[~.Analysis]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'get_analysis' not in self._stubs: - self._stubs['get_analysis'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetAnalysis', - request_serializer=contact_center_insights.GetAnalysisRequest.serialize, - response_deserializer=resources.Analysis.deserialize, - ) - return self._stubs['get_analysis'] - - @property - def list_analyses(self) -> Callable[ - [contact_center_insights.ListAnalysesRequest], - Awaitable[contact_center_insights.ListAnalysesResponse]]: - r"""Return a callable for the list analyses method over gRPC. - - Lists analyses. - - Returns: - Callable[[~.ListAnalysesRequest], - Awaitable[~.ListAnalysesResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'list_analyses' not in self._stubs: - self._stubs['list_analyses'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListAnalyses', - request_serializer=contact_center_insights.ListAnalysesRequest.serialize, - response_deserializer=contact_center_insights.ListAnalysesResponse.deserialize, - ) - return self._stubs['list_analyses'] - - @property - def delete_analysis(self) -> Callable[ - [contact_center_insights.DeleteAnalysisRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete analysis method over gRPC. - - Deletes an analysis. - - Returns: - Callable[[~.DeleteAnalysisRequest], - Awaitable[~.Empty]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_analysis' not in self._stubs: - self._stubs['delete_analysis'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteAnalysis', - request_serializer=contact_center_insights.DeleteAnalysisRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_analysis'] - - @property - def bulk_analyze_conversations(self) -> Callable[ - [contact_center_insights.BulkAnalyzeConversationsRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the bulk analyze conversations method over gRPC. - - Analyzes multiple conversations in a single request. - - Returns: - Callable[[~.BulkAnalyzeConversationsRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'bulk_analyze_conversations' not in self._stubs: - self._stubs['bulk_analyze_conversations'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/BulkAnalyzeConversations', - request_serializer=contact_center_insights.BulkAnalyzeConversationsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['bulk_analyze_conversations'] - - @property - def ingest_conversations(self) -> Callable[ - [contact_center_insights.IngestConversationsRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the ingest conversations method over gRPC. - - Imports conversations and processes them according to - the user's configuration. - - Returns: - Callable[[~.IngestConversationsRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'ingest_conversations' not in self._stubs: - self._stubs['ingest_conversations'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/IngestConversations', - request_serializer=contact_center_insights.IngestConversationsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['ingest_conversations'] - - @property - def export_insights_data(self) -> Callable[ - [contact_center_insights.ExportInsightsDataRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the export insights data method over gRPC. - - Export insights data to a destination defined in the - request body. - - Returns: - Callable[[~.ExportInsightsDataRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'export_insights_data' not in self._stubs: - self._stubs['export_insights_data'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ExportInsightsData', - request_serializer=contact_center_insights.ExportInsightsDataRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['export_insights_data'] - - @property - def create_issue_model(self) -> Callable[ - [contact_center_insights.CreateIssueModelRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create issue model method over gRPC. - - Creates an issue model. - - Returns: - Callable[[~.CreateIssueModelRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'create_issue_model' not in self._stubs: - self._stubs['create_issue_model'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateIssueModel', - request_serializer=contact_center_insights.CreateIssueModelRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_issue_model'] - - @property - def update_issue_model(self) -> Callable[ - [contact_center_insights.UpdateIssueModelRequest], - Awaitable[resources.IssueModel]]: - r"""Return a callable for the update issue model method over gRPC. - - Updates an issue model. - - Returns: - Callable[[~.UpdateIssueModelRequest], - Awaitable[~.IssueModel]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'update_issue_model' not in self._stubs: - self._stubs['update_issue_model'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateIssueModel', - request_serializer=contact_center_insights.UpdateIssueModelRequest.serialize, - response_deserializer=resources.IssueModel.deserialize, - ) - return self._stubs['update_issue_model'] - - @property - def get_issue_model(self) -> Callable[ - [contact_center_insights.GetIssueModelRequest], - Awaitable[resources.IssueModel]]: - r"""Return a callable for the get issue model method over gRPC. - - Gets an issue model. - - Returns: - Callable[[~.GetIssueModelRequest], - Awaitable[~.IssueModel]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'get_issue_model' not in self._stubs: - self._stubs['get_issue_model'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetIssueModel', - request_serializer=contact_center_insights.GetIssueModelRequest.serialize, - response_deserializer=resources.IssueModel.deserialize, - ) - return self._stubs['get_issue_model'] - - @property - def list_issue_models(self) -> Callable[ - [contact_center_insights.ListIssueModelsRequest], - Awaitable[contact_center_insights.ListIssueModelsResponse]]: - r"""Return a callable for the list issue models method over gRPC. - - Lists issue models. - - Returns: - Callable[[~.ListIssueModelsRequest], - Awaitable[~.ListIssueModelsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'list_issue_models' not in self._stubs: - self._stubs['list_issue_models'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListIssueModels', - request_serializer=contact_center_insights.ListIssueModelsRequest.serialize, - response_deserializer=contact_center_insights.ListIssueModelsResponse.deserialize, - ) - return self._stubs['list_issue_models'] - - @property - def delete_issue_model(self) -> Callable[ - [contact_center_insights.DeleteIssueModelRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete issue model method over gRPC. - - Deletes an issue model. - - Returns: - Callable[[~.DeleteIssueModelRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_issue_model' not in self._stubs: - self._stubs['delete_issue_model'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteIssueModel', - request_serializer=contact_center_insights.DeleteIssueModelRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_issue_model'] - - @property - def deploy_issue_model(self) -> Callable[ - [contact_center_insights.DeployIssueModelRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the deploy issue model method over gRPC. - - Deploys an issue model. Returns an error if a model - is already deployed. An issue model can only be used in - analysis after it has been deployed. - - Returns: - Callable[[~.DeployIssueModelRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'deploy_issue_model' not in self._stubs: - self._stubs['deploy_issue_model'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeployIssueModel', - request_serializer=contact_center_insights.DeployIssueModelRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['deploy_issue_model'] - - @property - def undeploy_issue_model(self) -> Callable[ - [contact_center_insights.UndeployIssueModelRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the undeploy issue model method over gRPC. - - Undeploys an issue model. - An issue model can not be used in analysis after it has - been undeployed. - - Returns: - Callable[[~.UndeployIssueModelRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'undeploy_issue_model' not in self._stubs: - self._stubs['undeploy_issue_model'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UndeployIssueModel', - request_serializer=contact_center_insights.UndeployIssueModelRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['undeploy_issue_model'] - - @property - def get_issue(self) -> Callable[ - [contact_center_insights.GetIssueRequest], - Awaitable[resources.Issue]]: - r"""Return a callable for the get issue method over gRPC. - - Gets an issue. - - Returns: - Callable[[~.GetIssueRequest], - Awaitable[~.Issue]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'get_issue' not in self._stubs: - self._stubs['get_issue'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetIssue', - request_serializer=contact_center_insights.GetIssueRequest.serialize, - response_deserializer=resources.Issue.deserialize, - ) - return self._stubs['get_issue'] - - @property - def list_issues(self) -> Callable[ - [contact_center_insights.ListIssuesRequest], - Awaitable[contact_center_insights.ListIssuesResponse]]: - r"""Return a callable for the list issues method over gRPC. - - Lists issues. - - Returns: - Callable[[~.ListIssuesRequest], - Awaitable[~.ListIssuesResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'list_issues' not in self._stubs: - self._stubs['list_issues'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListIssues', - request_serializer=contact_center_insights.ListIssuesRequest.serialize, - response_deserializer=contact_center_insights.ListIssuesResponse.deserialize, - ) - return self._stubs['list_issues'] - - @property - def update_issue(self) -> Callable[ - [contact_center_insights.UpdateIssueRequest], - Awaitable[resources.Issue]]: - r"""Return a callable for the update issue method over gRPC. - - Updates an issue. - - Returns: - Callable[[~.UpdateIssueRequest], - Awaitable[~.Issue]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'update_issue' not in self._stubs: - self._stubs['update_issue'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateIssue', - request_serializer=contact_center_insights.UpdateIssueRequest.serialize, - response_deserializer=resources.Issue.deserialize, - ) - return self._stubs['update_issue'] - - @property - def delete_issue(self) -> Callable[ - [contact_center_insights.DeleteIssueRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete issue method over gRPC. - - Deletes an issue. - - Returns: - Callable[[~.DeleteIssueRequest], - Awaitable[~.Empty]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_issue' not in self._stubs: - self._stubs['delete_issue'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteIssue', - request_serializer=contact_center_insights.DeleteIssueRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_issue'] - - @property - def calculate_issue_model_stats(self) -> Callable[ - [contact_center_insights.CalculateIssueModelStatsRequest], - Awaitable[contact_center_insights.CalculateIssueModelStatsResponse]]: - r"""Return a callable for the calculate issue model stats method over gRPC. - - Gets an issue model's statistics. - - Returns: - Callable[[~.CalculateIssueModelStatsRequest], - Awaitable[~.CalculateIssueModelStatsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'calculate_issue_model_stats' not in self._stubs: - self._stubs['calculate_issue_model_stats'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CalculateIssueModelStats', - request_serializer=contact_center_insights.CalculateIssueModelStatsRequest.serialize, - response_deserializer=contact_center_insights.CalculateIssueModelStatsResponse.deserialize, - ) - return self._stubs['calculate_issue_model_stats'] - - @property - def create_phrase_matcher(self) -> Callable[ - [contact_center_insights.CreatePhraseMatcherRequest], - Awaitable[resources.PhraseMatcher]]: - r"""Return a callable for the create phrase matcher method over gRPC. - - Creates a phrase matcher. - - Returns: - Callable[[~.CreatePhraseMatcherRequest], - Awaitable[~.PhraseMatcher]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'create_phrase_matcher' not in self._stubs: - self._stubs['create_phrase_matcher'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreatePhraseMatcher', - request_serializer=contact_center_insights.CreatePhraseMatcherRequest.serialize, - response_deserializer=resources.PhraseMatcher.deserialize, - ) - return self._stubs['create_phrase_matcher'] - - @property - def get_phrase_matcher(self) -> Callable[ - [contact_center_insights.GetPhraseMatcherRequest], - Awaitable[resources.PhraseMatcher]]: - r"""Return a callable for the get phrase matcher method over gRPC. - - Gets a phrase matcher. - - Returns: - Callable[[~.GetPhraseMatcherRequest], - Awaitable[~.PhraseMatcher]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'get_phrase_matcher' not in self._stubs: - self._stubs['get_phrase_matcher'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetPhraseMatcher', - request_serializer=contact_center_insights.GetPhraseMatcherRequest.serialize, - response_deserializer=resources.PhraseMatcher.deserialize, - ) - return self._stubs['get_phrase_matcher'] - - @property - def list_phrase_matchers(self) -> Callable[ - [contact_center_insights.ListPhraseMatchersRequest], - Awaitable[contact_center_insights.ListPhraseMatchersResponse]]: - r"""Return a callable for the list phrase matchers method over gRPC. - - Lists phrase matchers. - - Returns: - Callable[[~.ListPhraseMatchersRequest], - Awaitable[~.ListPhraseMatchersResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'list_phrase_matchers' not in self._stubs: - self._stubs['list_phrase_matchers'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListPhraseMatchers', - request_serializer=contact_center_insights.ListPhraseMatchersRequest.serialize, - response_deserializer=contact_center_insights.ListPhraseMatchersResponse.deserialize, - ) - return self._stubs['list_phrase_matchers'] - - @property - def delete_phrase_matcher(self) -> Callable[ - [contact_center_insights.DeletePhraseMatcherRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete phrase matcher method over gRPC. - - Deletes a phrase matcher. - - Returns: - Callable[[~.DeletePhraseMatcherRequest], - Awaitable[~.Empty]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_phrase_matcher' not in self._stubs: - self._stubs['delete_phrase_matcher'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeletePhraseMatcher', - request_serializer=contact_center_insights.DeletePhraseMatcherRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_phrase_matcher'] - - @property - def update_phrase_matcher(self) -> Callable[ - [contact_center_insights.UpdatePhraseMatcherRequest], - Awaitable[resources.PhraseMatcher]]: - r"""Return a callable for the update phrase matcher method over gRPC. - - Updates a phrase matcher. - - Returns: - Callable[[~.UpdatePhraseMatcherRequest], - Awaitable[~.PhraseMatcher]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'update_phrase_matcher' not in self._stubs: - self._stubs['update_phrase_matcher'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdatePhraseMatcher', - request_serializer=contact_center_insights.UpdatePhraseMatcherRequest.serialize, - response_deserializer=resources.PhraseMatcher.deserialize, - ) - return self._stubs['update_phrase_matcher'] - - @property - def calculate_stats(self) -> Callable[ - [contact_center_insights.CalculateStatsRequest], - Awaitable[contact_center_insights.CalculateStatsResponse]]: - r"""Return a callable for the calculate stats method over gRPC. - - Gets conversation statistics. - - Returns: - Callable[[~.CalculateStatsRequest], - Awaitable[~.CalculateStatsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'calculate_stats' not in self._stubs: - self._stubs['calculate_stats'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CalculateStats', - request_serializer=contact_center_insights.CalculateStatsRequest.serialize, - response_deserializer=contact_center_insights.CalculateStatsResponse.deserialize, - ) - return self._stubs['calculate_stats'] - - @property - def get_settings(self) -> Callable[ - [contact_center_insights.GetSettingsRequest], - Awaitable[resources.Settings]]: - r"""Return a callable for the get settings method over gRPC. - - Gets project-level settings. - - Returns: - Callable[[~.GetSettingsRequest], - Awaitable[~.Settings]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'get_settings' not in self._stubs: - self._stubs['get_settings'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetSettings', - request_serializer=contact_center_insights.GetSettingsRequest.serialize, - response_deserializer=resources.Settings.deserialize, - ) - return self._stubs['get_settings'] - - @property - def update_settings(self) -> Callable[ - [contact_center_insights.UpdateSettingsRequest], - Awaitable[resources.Settings]]: - r"""Return a callable for the update settings method over gRPC. - - Updates project-level settings. - - Returns: - Callable[[~.UpdateSettingsRequest], - Awaitable[~.Settings]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'update_settings' not in self._stubs: - self._stubs['update_settings'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateSettings', - request_serializer=contact_center_insights.UpdateSettingsRequest.serialize, - response_deserializer=resources.Settings.deserialize, - ) - return self._stubs['update_settings'] - - @property - def create_view(self) -> Callable[ - [contact_center_insights.CreateViewRequest], - Awaitable[resources.View]]: - r"""Return a callable for the create view method over gRPC. - - Creates a view. - - Returns: - Callable[[~.CreateViewRequest], - Awaitable[~.View]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'create_view' not in self._stubs: - self._stubs['create_view'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateView', - request_serializer=contact_center_insights.CreateViewRequest.serialize, - response_deserializer=resources.View.deserialize, - ) - return self._stubs['create_view'] - - @property - def get_view(self) -> Callable[ - [contact_center_insights.GetViewRequest], - Awaitable[resources.View]]: - r"""Return a callable for the get view method over gRPC. - - Gets a view. - - Returns: - Callable[[~.GetViewRequest], - Awaitable[~.View]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'get_view' not in self._stubs: - self._stubs['get_view'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/GetView', - request_serializer=contact_center_insights.GetViewRequest.serialize, - response_deserializer=resources.View.deserialize, - ) - return self._stubs['get_view'] - - @property - def list_views(self) -> Callable[ - [contact_center_insights.ListViewsRequest], - Awaitable[contact_center_insights.ListViewsResponse]]: - r"""Return a callable for the list views method over gRPC. - - Lists views. - - Returns: - Callable[[~.ListViewsRequest], - Awaitable[~.ListViewsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'list_views' not in self._stubs: - self._stubs['list_views'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/ListViews', - request_serializer=contact_center_insights.ListViewsRequest.serialize, - response_deserializer=contact_center_insights.ListViewsResponse.deserialize, - ) - return self._stubs['list_views'] - - @property - def update_view(self) -> Callable[ - [contact_center_insights.UpdateViewRequest], - Awaitable[resources.View]]: - r"""Return a callable for the update view method over gRPC. - - Updates a view. - - Returns: - Callable[[~.UpdateViewRequest], - Awaitable[~.View]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'update_view' not in self._stubs: - self._stubs['update_view'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateView', - request_serializer=contact_center_insights.UpdateViewRequest.serialize, - response_deserializer=resources.View.deserialize, - ) - return self._stubs['update_view'] - - @property - def delete_view(self) -> Callable[ - [contact_center_insights.DeleteViewRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete view method over gRPC. - - Deletes a view. - - Returns: - Callable[[~.DeleteViewRequest], - Awaitable[~.Empty]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_view' not in self._stubs: - self._stubs['delete_view'] = self.grpc_channel.unary_unary( - '/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteView', - request_serializer=contact_center_insights.DeleteViewRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_view'] - - def close(self): - return self.grpc_channel.close() - - @property - def cancel_operation( - self, - ) -> Callable[[operations_pb2.CancelOperationRequest], None]: - r"""Return a callable for the cancel_operation method over gRPC. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( - "/google.longrunning.Operations/CancelOperation", - request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, - response_deserializer=None, - ) - return self._stubs["cancel_operation"] - - @property - def get_operation( - self, - ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: - r"""Return a callable for the get_operation method over gRPC. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( - "/google.longrunning.Operations/GetOperation", - request_serializer=operations_pb2.GetOperationRequest.SerializeToString, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["get_operation"] - - @property - def list_operations( - self, - ) -> Callable[[operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse]: - r"""Return a callable for the list_operations method over gRPC. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( - "/google.longrunning.Operations/ListOperations", - request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, - response_deserializer=operations_pb2.ListOperationsResponse.FromString, - ) - return self._stubs["list_operations"] - - -__all__ = ( - 'ContactCenterInsightsGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/rest.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/rest.py deleted file mode 100644 index 38233f5e5e0c..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/rest.py +++ /dev/null @@ -1,4718 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# - -from google.auth.transport.requests import AuthorizedSession # type: ignore -import json # type: ignore -import grpc # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.api_core import exceptions as core_exceptions -from google.api_core import retry as retries -from google.api_core import rest_helpers -from google.api_core import rest_streaming -from google.api_core import path_template -from google.api_core import gapic_v1 - -from google.protobuf import json_format -from google.api_core import operations_v1 -from requests import __version__ as requests_version -import dataclasses -import re -from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union -import warnings - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - - -from google.cloud.contact_center_insights_v1.types import contact_center_insights -from google.cloud.contact_center_insights_v1.types import resources -from google.protobuf import empty_pb2 # type: ignore -from google.longrunning import operations_pb2 # type: ignore - -from .base import ContactCenterInsightsTransport, DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, - grpc_version=None, - rest_version=requests_version, -) - - -class ContactCenterInsightsRestInterceptor: - """Interceptor for ContactCenterInsights. - - Interceptors are used to manipulate requests, request metadata, and responses - in arbitrary ways. - Example use cases include: - * Logging - * Verifying requests according to service or custom semantics - * Stripping extraneous information from responses - - These use cases and more can be enabled by injecting an - instance of a custom subclass when constructing the ContactCenterInsightsRestTransport. - - .. code-block:: python - class MyCustomContactCenterInsightsInterceptor(ContactCenterInsightsRestInterceptor): - def pre_bulk_analyze_conversations(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_bulk_analyze_conversations(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_calculate_issue_model_stats(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_calculate_issue_model_stats(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_calculate_stats(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_calculate_stats(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_analysis(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_analysis(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_conversation(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_conversation(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_issue_model(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_issue_model(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_phrase_matcher(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_phrase_matcher(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_view(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_view(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_analysis(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_delete_conversation(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_delete_issue(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_delete_issue_model(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_issue_model(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_phrase_matcher(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_delete_view(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_deploy_issue_model(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_deploy_issue_model(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_export_insights_data(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_export_insights_data(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_analysis(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_analysis(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_conversation(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_conversation(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_issue(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_issue(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_issue_model(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_issue_model(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_phrase_matcher(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_phrase_matcher(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_settings(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_settings(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_view(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_view(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_ingest_conversations(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_ingest_conversations(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_analyses(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_analyses(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_conversations(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_conversations(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_issue_models(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_issue_models(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_issues(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_issues(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_phrase_matchers(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_phrase_matchers(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_views(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_views(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_undeploy_issue_model(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_undeploy_issue_model(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_conversation(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_conversation(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_issue(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_issue(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_issue_model(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_issue_model(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_phrase_matcher(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_phrase_matcher(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_settings(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_settings(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_view(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_view(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_upload_conversation(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_upload_conversation(self, response): - logging.log(f"Received response: {response}") - return response - - transport = ContactCenterInsightsRestTransport(interceptor=MyCustomContactCenterInsightsInterceptor()) - client = ContactCenterInsightsClient(transport=transport) - - - """ - def pre_bulk_analyze_conversations(self, request: contact_center_insights.BulkAnalyzeConversationsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.BulkAnalyzeConversationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for bulk_analyze_conversations - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_bulk_analyze_conversations(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for bulk_analyze_conversations - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_calculate_issue_model_stats(self, request: contact_center_insights.CalculateIssueModelStatsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.CalculateIssueModelStatsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for calculate_issue_model_stats - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_calculate_issue_model_stats(self, response: contact_center_insights.CalculateIssueModelStatsResponse) -> contact_center_insights.CalculateIssueModelStatsResponse: - """Post-rpc interceptor for calculate_issue_model_stats - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_calculate_stats(self, request: contact_center_insights.CalculateStatsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.CalculateStatsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for calculate_stats - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_calculate_stats(self, response: contact_center_insights.CalculateStatsResponse) -> contact_center_insights.CalculateStatsResponse: - """Post-rpc interceptor for calculate_stats - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_create_analysis(self, request: contact_center_insights.CreateAnalysisRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.CreateAnalysisRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_analysis - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_create_analysis(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for create_analysis - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_create_conversation(self, request: contact_center_insights.CreateConversationRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.CreateConversationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_conversation - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_create_conversation(self, response: resources.Conversation) -> resources.Conversation: - """Post-rpc interceptor for create_conversation - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_create_issue_model(self, request: contact_center_insights.CreateIssueModelRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.CreateIssueModelRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_issue_model - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_create_issue_model(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for create_issue_model - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_create_phrase_matcher(self, request: contact_center_insights.CreatePhraseMatcherRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.CreatePhraseMatcherRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_phrase_matcher - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_create_phrase_matcher(self, response: resources.PhraseMatcher) -> resources.PhraseMatcher: - """Post-rpc interceptor for create_phrase_matcher - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_create_view(self, request: contact_center_insights.CreateViewRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.CreateViewRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_view - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_create_view(self, response: resources.View) -> resources.View: - """Post-rpc interceptor for create_view - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_delete_analysis(self, request: contact_center_insights.DeleteAnalysisRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.DeleteAnalysisRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_analysis - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def pre_delete_conversation(self, request: contact_center_insights.DeleteConversationRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.DeleteConversationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_conversation - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def pre_delete_issue(self, request: contact_center_insights.DeleteIssueRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.DeleteIssueRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_issue - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def pre_delete_issue_model(self, request: contact_center_insights.DeleteIssueModelRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.DeleteIssueModelRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_issue_model - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_delete_issue_model(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_issue_model - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_delete_phrase_matcher(self, request: contact_center_insights.DeletePhraseMatcherRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.DeletePhraseMatcherRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_phrase_matcher - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def pre_delete_view(self, request: contact_center_insights.DeleteViewRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.DeleteViewRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_view - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def pre_deploy_issue_model(self, request: contact_center_insights.DeployIssueModelRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.DeployIssueModelRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for deploy_issue_model - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_deploy_issue_model(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for deploy_issue_model - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_export_insights_data(self, request: contact_center_insights.ExportInsightsDataRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.ExportInsightsDataRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for export_insights_data - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_export_insights_data(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for export_insights_data - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_get_analysis(self, request: contact_center_insights.GetAnalysisRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.GetAnalysisRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_analysis - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_get_analysis(self, response: resources.Analysis) -> resources.Analysis: - """Post-rpc interceptor for get_analysis - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_get_conversation(self, request: contact_center_insights.GetConversationRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.GetConversationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_conversation - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_get_conversation(self, response: resources.Conversation) -> resources.Conversation: - """Post-rpc interceptor for get_conversation - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_get_issue(self, request: contact_center_insights.GetIssueRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.GetIssueRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_issue - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_get_issue(self, response: resources.Issue) -> resources.Issue: - """Post-rpc interceptor for get_issue - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_get_issue_model(self, request: contact_center_insights.GetIssueModelRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.GetIssueModelRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_issue_model - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_get_issue_model(self, response: resources.IssueModel) -> resources.IssueModel: - """Post-rpc interceptor for get_issue_model - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_get_phrase_matcher(self, request: contact_center_insights.GetPhraseMatcherRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.GetPhraseMatcherRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_phrase_matcher - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_get_phrase_matcher(self, response: resources.PhraseMatcher) -> resources.PhraseMatcher: - """Post-rpc interceptor for get_phrase_matcher - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_get_settings(self, request: contact_center_insights.GetSettingsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.GetSettingsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_settings - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_get_settings(self, response: resources.Settings) -> resources.Settings: - """Post-rpc interceptor for get_settings - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_get_view(self, request: contact_center_insights.GetViewRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.GetViewRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_view - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_get_view(self, response: resources.View) -> resources.View: - """Post-rpc interceptor for get_view - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_ingest_conversations(self, request: contact_center_insights.IngestConversationsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.IngestConversationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for ingest_conversations - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_ingest_conversations(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for ingest_conversations - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_list_analyses(self, request: contact_center_insights.ListAnalysesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.ListAnalysesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_analyses - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_list_analyses(self, response: contact_center_insights.ListAnalysesResponse) -> contact_center_insights.ListAnalysesResponse: - """Post-rpc interceptor for list_analyses - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_list_conversations(self, request: contact_center_insights.ListConversationsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.ListConversationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_conversations - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_list_conversations(self, response: contact_center_insights.ListConversationsResponse) -> contact_center_insights.ListConversationsResponse: - """Post-rpc interceptor for list_conversations - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_list_issue_models(self, request: contact_center_insights.ListIssueModelsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.ListIssueModelsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_issue_models - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_list_issue_models(self, response: contact_center_insights.ListIssueModelsResponse) -> contact_center_insights.ListIssueModelsResponse: - """Post-rpc interceptor for list_issue_models - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_list_issues(self, request: contact_center_insights.ListIssuesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.ListIssuesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_issues - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_list_issues(self, response: contact_center_insights.ListIssuesResponse) -> contact_center_insights.ListIssuesResponse: - """Post-rpc interceptor for list_issues - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_list_phrase_matchers(self, request: contact_center_insights.ListPhraseMatchersRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.ListPhraseMatchersRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_phrase_matchers - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_list_phrase_matchers(self, response: contact_center_insights.ListPhraseMatchersResponse) -> contact_center_insights.ListPhraseMatchersResponse: - """Post-rpc interceptor for list_phrase_matchers - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_list_views(self, request: contact_center_insights.ListViewsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.ListViewsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_views - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_list_views(self, response: contact_center_insights.ListViewsResponse) -> contact_center_insights.ListViewsResponse: - """Post-rpc interceptor for list_views - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_undeploy_issue_model(self, request: contact_center_insights.UndeployIssueModelRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.UndeployIssueModelRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for undeploy_issue_model - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_undeploy_issue_model(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for undeploy_issue_model - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_update_conversation(self, request: contact_center_insights.UpdateConversationRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.UpdateConversationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_conversation - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_update_conversation(self, response: resources.Conversation) -> resources.Conversation: - """Post-rpc interceptor for update_conversation - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_update_issue(self, request: contact_center_insights.UpdateIssueRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.UpdateIssueRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_issue - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_update_issue(self, response: resources.Issue) -> resources.Issue: - """Post-rpc interceptor for update_issue - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_update_issue_model(self, request: contact_center_insights.UpdateIssueModelRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.UpdateIssueModelRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_issue_model - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_update_issue_model(self, response: resources.IssueModel) -> resources.IssueModel: - """Post-rpc interceptor for update_issue_model - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_update_phrase_matcher(self, request: contact_center_insights.UpdatePhraseMatcherRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.UpdatePhraseMatcherRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_phrase_matcher - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_update_phrase_matcher(self, response: resources.PhraseMatcher) -> resources.PhraseMatcher: - """Post-rpc interceptor for update_phrase_matcher - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_update_settings(self, request: contact_center_insights.UpdateSettingsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.UpdateSettingsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_settings - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_update_settings(self, response: resources.Settings) -> resources.Settings: - """Post-rpc interceptor for update_settings - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_update_view(self, request: contact_center_insights.UpdateViewRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.UpdateViewRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_view - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_update_view(self, response: resources.View) -> resources.View: - """Post-rpc interceptor for update_view - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_upload_conversation(self, request: contact_center_insights.UploadConversationRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[contact_center_insights.UploadConversationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for upload_conversation - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_upload_conversation(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for upload_conversation - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - - def pre_cancel_operation( - self, request: operations_pb2.CancelOperationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for cancel_operation - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_cancel_operation( - self, response: None - ) -> None: - """Post-rpc interceptor for cancel_operation - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_get_operation( - self, request: operations_pb2.GetOperationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_operation - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_get_operation( - self, response: operations_pb2.Operation - ) -> operations_pb2.Operation: - """Post-rpc interceptor for get_operation - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - def pre_list_operations( - self, request: operations_pb2.ListOperationsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_operations - - Override in a subclass to manipulate the request or metadata - before they are sent to the ContactCenterInsights server. - """ - return request, metadata - - def post_list_operations( - self, response: operations_pb2.ListOperationsResponse - ) -> operations_pb2.ListOperationsResponse: - """Post-rpc interceptor for list_operations - - Override in a subclass to manipulate the response - after it is returned by the ContactCenterInsights server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class ContactCenterInsightsRestStub: - _session: AuthorizedSession - _host: str - _interceptor: ContactCenterInsightsRestInterceptor - - -class ContactCenterInsightsRestTransport(ContactCenterInsightsTransport): - """REST backend transport for ContactCenterInsights. - - An API that lets users analyze and explore their business - conversation data. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends JSON representations of protocol buffers over HTTP/1.1 - - """ - - def __init__(self, *, - host: str = 'contactcenterinsights.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - client_cert_source_for_mtls: Optional[Callable[[ - ], Tuple[bytes, bytes]]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - url_scheme: str = 'https', - interceptor: Optional[ContactCenterInsightsRestInterceptor] = None, - api_audience: Optional[str] = None, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if ``channel`` is provided. - client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client - certificate to configure mutual TLS HTTP channel. It is ignored - if ``channel`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you are developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - url_scheme: the protocol scheme for the API endpoint. Normally - "https", but for testing or local servers, - "http" can be specified. - """ - # Run the base constructor - # TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc. - # TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the - # credentials object - maybe_url_match = re.match("^(?Phttp(?:s)?://)?(?P.*)$", host) - if maybe_url_match is None: - raise ValueError(f"Unexpected hostname structure: {host}") # pragma: NO COVER - - url_match_items = maybe_url_match.groupdict() - - host = f"{url_scheme}://{host}" if not url_match_items["scheme"] else host - - super().__init__( - host=host, - credentials=credentials, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - api_audience=api_audience - ) - self._session = AuthorizedSession( - self._credentials, default_host=self.DEFAULT_HOST) - self._operations_client: Optional[operations_v1.AbstractOperationsClient] = None - if client_cert_source_for_mtls: - self._session.configure_mtls_channel(client_cert_source_for_mtls) - self._interceptor = interceptor or ContactCenterInsightsRestInterceptor() - self._prep_wrapped_messages(client_info) - - @property - def operations_client(self) -> operations_v1.AbstractOperationsClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Only create a new client if we do not already have one. - if self._operations_client is None: - http_options: Dict[str, List[Dict[str, str]]] = { - 'google.longrunning.Operations.CancelOperation': [ - { - 'method': 'post', - 'uri': '/v1/{name=projects/*/locations/*/operations/*}:cancel', - }, - ], - 'google.longrunning.Operations.GetOperation': [ - { - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/operations/*}', - }, - ], - 'google.longrunning.Operations.ListOperations': [ - { - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*}/operations', - }, - ], - } - - rest_transport = operations_v1.OperationsRestTransport( - host=self._host, - # use the credentials which are saved - credentials=self._credentials, - scopes=self._scopes, - http_options=http_options, - path_prefix="v1") - - self._operations_client = operations_v1.AbstractOperationsClient(transport=rest_transport) - - # Return the client from cache. - return self._operations_client - - class _BulkAnalyzeConversations(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("BulkAnalyzeConversations") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.BulkAnalyzeConversationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the bulk analyze - conversations method over HTTP. - - Args: - request (~.contact_center_insights.BulkAnalyzeConversationsRequest): - The request object. The request to analyze conversations - in bulk. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/conversations:bulkAnalyze', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_bulk_analyze_conversations(request, metadata) - pb_request = contact_center_insights.BulkAnalyzeConversationsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_bulk_analyze_conversations(resp) - return resp - - class _CalculateIssueModelStats(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("CalculateIssueModelStats") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.CalculateIssueModelStatsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> contact_center_insights.CalculateIssueModelStatsResponse: - r"""Call the calculate issue model - stats method over HTTP. - - Args: - request (~.contact_center_insights.CalculateIssueModelStatsRequest): - The request object. Request to get statistics of an issue - model. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.contact_center_insights.CalculateIssueModelStatsResponse: - Response of querying an issue model's - statistics. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{issue_model=projects/*/locations/*/issueModels/*}:calculateIssueModelStats', - }, - ] - request, metadata = self._interceptor.pre_calculate_issue_model_stats(request, metadata) - pb_request = contact_center_insights.CalculateIssueModelStatsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = contact_center_insights.CalculateIssueModelStatsResponse() - pb_resp = contact_center_insights.CalculateIssueModelStatsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_calculate_issue_model_stats(resp) - return resp - - class _CalculateStats(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("CalculateStats") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.CalculateStatsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> contact_center_insights.CalculateStatsResponse: - r"""Call the calculate stats method over HTTP. - - Args: - request (~.contact_center_insights.CalculateStatsRequest): - The request object. The request for calculating - conversation statistics. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.contact_center_insights.CalculateStatsResponse: - The response for calculating - conversation statistics. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{location=projects/*/locations/*}/conversations:calculateStats', - }, - ] - request, metadata = self._interceptor.pre_calculate_stats(request, metadata) - pb_request = contact_center_insights.CalculateStatsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = contact_center_insights.CalculateStatsResponse() - pb_resp = contact_center_insights.CalculateStatsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_calculate_stats(resp) - return resp - - class _CreateAnalysis(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("CreateAnalysis") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.CreateAnalysisRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the create analysis method over HTTP. - - Args: - request (~.contact_center_insights.CreateAnalysisRequest): - The request object. The request to create an analysis. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*/conversations/*}/analyses', - 'body': 'analysis', - }, - ] - request, metadata = self._interceptor.pre_create_analysis(request, metadata) - pb_request = contact_center_insights.CreateAnalysisRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_analysis(resp) - return resp - - class _CreateConversation(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("CreateConversation") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.CreateConversationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> resources.Conversation: - r"""Call the create conversation method over HTTP. - - Args: - request (~.contact_center_insights.CreateConversationRequest): - The request object. Request to create a conversation. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.resources.Conversation: - The conversation resource. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/conversations', - 'body': 'conversation', - }, - ] - request, metadata = self._interceptor.pre_create_conversation(request, metadata) - pb_request = contact_center_insights.CreateConversationRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = resources.Conversation() - pb_resp = resources.Conversation.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_conversation(resp) - return resp - - class _CreateIssueModel(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("CreateIssueModel") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.CreateIssueModelRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the create issue model method over HTTP. - - Args: - request (~.contact_center_insights.CreateIssueModelRequest): - The request object. The request to create an issue model. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/issueModels', - 'body': 'issue_model', - }, - ] - request, metadata = self._interceptor.pre_create_issue_model(request, metadata) - pb_request = contact_center_insights.CreateIssueModelRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_issue_model(resp) - return resp - - class _CreatePhraseMatcher(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("CreatePhraseMatcher") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.CreatePhraseMatcherRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> resources.PhraseMatcher: - r"""Call the create phrase matcher method over HTTP. - - Args: - request (~.contact_center_insights.CreatePhraseMatcherRequest): - The request object. Request to create a phrase matcher. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.resources.PhraseMatcher: - The phrase matcher resource. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/phraseMatchers', - 'body': 'phrase_matcher', - }, - ] - request, metadata = self._interceptor.pre_create_phrase_matcher(request, metadata) - pb_request = contact_center_insights.CreatePhraseMatcherRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = resources.PhraseMatcher() - pb_resp = resources.PhraseMatcher.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_phrase_matcher(resp) - return resp - - class _CreateView(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("CreateView") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.CreateViewRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> resources.View: - r"""Call the create view method over HTTP. - - Args: - request (~.contact_center_insights.CreateViewRequest): - The request object. The request to create a view. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.resources.View: - The View resource. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/views', - 'body': 'view', - }, - ] - request, metadata = self._interceptor.pre_create_view(request, metadata) - pb_request = contact_center_insights.CreateViewRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = resources.View() - pb_resp = resources.View.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_view(resp) - return resp - - class _DeleteAnalysis(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("DeleteAnalysis") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.DeleteAnalysisRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete analysis method over HTTP. - - Args: - request (~.contact_center_insights.DeleteAnalysisRequest): - The request object. The request to delete an analysis. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/conversations/*/analyses/*}', - }, - ] - request, metadata = self._interceptor.pre_delete_analysis(request, metadata) - pb_request = contact_center_insights.DeleteAnalysisRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - class _DeleteConversation(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("DeleteConversation") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.DeleteConversationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete conversation method over HTTP. - - Args: - request (~.contact_center_insights.DeleteConversationRequest): - The request object. The request to delete a conversation. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/conversations/*}', - }, - ] - request, metadata = self._interceptor.pre_delete_conversation(request, metadata) - pb_request = contact_center_insights.DeleteConversationRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - class _DeleteIssue(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("DeleteIssue") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.DeleteIssueRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete issue method over HTTP. - - Args: - request (~.contact_center_insights.DeleteIssueRequest): - The request object. The request to delete an issue. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/issueModels/*/issues/*}', - }, - ] - request, metadata = self._interceptor.pre_delete_issue(request, metadata) - pb_request = contact_center_insights.DeleteIssueRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - class _DeleteIssueModel(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("DeleteIssueModel") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.DeleteIssueModelRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete issue model method over HTTP. - - Args: - request (~.contact_center_insights.DeleteIssueModelRequest): - The request object. The request to delete an issue model. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/issueModels/*}', - }, - ] - request, metadata = self._interceptor.pre_delete_issue_model(request, metadata) - pb_request = contact_center_insights.DeleteIssueModelRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_delete_issue_model(resp) - return resp - - class _DeletePhraseMatcher(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("DeletePhraseMatcher") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.DeletePhraseMatcherRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete phrase matcher method over HTTP. - - Args: - request (~.contact_center_insights.DeletePhraseMatcherRequest): - The request object. The request to delete a phrase - matcher. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/phraseMatchers/*}', - }, - ] - request, metadata = self._interceptor.pre_delete_phrase_matcher(request, metadata) - pb_request = contact_center_insights.DeletePhraseMatcherRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - class _DeleteView(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("DeleteView") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.DeleteViewRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete view method over HTTP. - - Args: - request (~.contact_center_insights.DeleteViewRequest): - The request object. The request to delete a view. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/views/*}', - }, - ] - request, metadata = self._interceptor.pre_delete_view(request, metadata) - pb_request = contact_center_insights.DeleteViewRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - class _DeployIssueModel(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("DeployIssueModel") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.DeployIssueModelRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the deploy issue model method over HTTP. - - Args: - request (~.contact_center_insights.DeployIssueModelRequest): - The request object. The request to deploy an issue model. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{name=projects/*/locations/*/issueModels/*}:deploy', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_deploy_issue_model(request, metadata) - pb_request = contact_center_insights.DeployIssueModelRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_deploy_issue_model(resp) - return resp - - class _ExportInsightsData(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("ExportInsightsData") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.ExportInsightsDataRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the export insights data method over HTTP. - - Args: - request (~.contact_center_insights.ExportInsightsDataRequest): - The request object. The request to export insights. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/insightsdata:export', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_export_insights_data(request, metadata) - pb_request = contact_center_insights.ExportInsightsDataRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_export_insights_data(resp) - return resp - - class _GetAnalysis(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("GetAnalysis") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.GetAnalysisRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> resources.Analysis: - r"""Call the get analysis method over HTTP. - - Args: - request (~.contact_center_insights.GetAnalysisRequest): - The request object. The request to get an analysis. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.resources.Analysis: - The analysis resource. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/conversations/*/analyses/*}', - }, - ] - request, metadata = self._interceptor.pre_get_analysis(request, metadata) - pb_request = contact_center_insights.GetAnalysisRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = resources.Analysis() - pb_resp = resources.Analysis.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_analysis(resp) - return resp - - class _GetConversation(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("GetConversation") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.GetConversationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> resources.Conversation: - r"""Call the get conversation method over HTTP. - - Args: - request (~.contact_center_insights.GetConversationRequest): - The request object. The request to get a conversation. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.resources.Conversation: - The conversation resource. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/conversations/*}', - }, - ] - request, metadata = self._interceptor.pre_get_conversation(request, metadata) - pb_request = contact_center_insights.GetConversationRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = resources.Conversation() - pb_resp = resources.Conversation.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_conversation(resp) - return resp - - class _GetIssue(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("GetIssue") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.GetIssueRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> resources.Issue: - r"""Call the get issue method over HTTP. - - Args: - request (~.contact_center_insights.GetIssueRequest): - The request object. The request to get an issue. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.resources.Issue: - The issue resource. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/issueModels/*/issues/*}', - }, - ] - request, metadata = self._interceptor.pre_get_issue(request, metadata) - pb_request = contact_center_insights.GetIssueRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = resources.Issue() - pb_resp = resources.Issue.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_issue(resp) - return resp - - class _GetIssueModel(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("GetIssueModel") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.GetIssueModelRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> resources.IssueModel: - r"""Call the get issue model method over HTTP. - - Args: - request (~.contact_center_insights.GetIssueModelRequest): - The request object. The request to get an issue model. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.resources.IssueModel: - The issue model resource. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/issueModels/*}', - }, - ] - request, metadata = self._interceptor.pre_get_issue_model(request, metadata) - pb_request = contact_center_insights.GetIssueModelRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = resources.IssueModel() - pb_resp = resources.IssueModel.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_issue_model(resp) - return resp - - class _GetPhraseMatcher(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("GetPhraseMatcher") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.GetPhraseMatcherRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> resources.PhraseMatcher: - r"""Call the get phrase matcher method over HTTP. - - Args: - request (~.contact_center_insights.GetPhraseMatcherRequest): - The request object. The request to get a a phrase - matcher. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.resources.PhraseMatcher: - The phrase matcher resource. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/phraseMatchers/*}', - }, - ] - request, metadata = self._interceptor.pre_get_phrase_matcher(request, metadata) - pb_request = contact_center_insights.GetPhraseMatcherRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = resources.PhraseMatcher() - pb_resp = resources.PhraseMatcher.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_phrase_matcher(resp) - return resp - - class _GetSettings(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("GetSettings") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.GetSettingsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> resources.Settings: - r"""Call the get settings method over HTTP. - - Args: - request (~.contact_center_insights.GetSettingsRequest): - The request object. The request to get project-level - settings. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.resources.Settings: - The settings resource. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/settings}', - }, - ] - request, metadata = self._interceptor.pre_get_settings(request, metadata) - pb_request = contact_center_insights.GetSettingsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = resources.Settings() - pb_resp = resources.Settings.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_settings(resp) - return resp - - class _GetView(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("GetView") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.GetViewRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> resources.View: - r"""Call the get view method over HTTP. - - Args: - request (~.contact_center_insights.GetViewRequest): - The request object. The request to get a view. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.resources.View: - The View resource. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/views/*}', - }, - ] - request, metadata = self._interceptor.pre_get_view(request, metadata) - pb_request = contact_center_insights.GetViewRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = resources.View() - pb_resp = resources.View.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_view(resp) - return resp - - class _IngestConversations(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("IngestConversations") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.IngestConversationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the ingest conversations method over HTTP. - - Args: - request (~.contact_center_insights.IngestConversationsRequest): - The request object. The request to ingest conversations. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/conversations:ingest', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_ingest_conversations(request, metadata) - pb_request = contact_center_insights.IngestConversationsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_ingest_conversations(resp) - return resp - - class _ListAnalyses(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("ListAnalyses") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.ListAnalysesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> contact_center_insights.ListAnalysesResponse: - r"""Call the list analyses method over HTTP. - - Args: - request (~.contact_center_insights.ListAnalysesRequest): - The request object. The request to list analyses. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.contact_center_insights.ListAnalysesResponse: - The response to list analyses. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*/conversations/*}/analyses', - }, - ] - request, metadata = self._interceptor.pre_list_analyses(request, metadata) - pb_request = contact_center_insights.ListAnalysesRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = contact_center_insights.ListAnalysesResponse() - pb_resp = contact_center_insights.ListAnalysesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_analyses(resp) - return resp - - class _ListConversations(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("ListConversations") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.ListConversationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> contact_center_insights.ListConversationsResponse: - r"""Call the list conversations method over HTTP. - - Args: - request (~.contact_center_insights.ListConversationsRequest): - The request object. Request to list conversations. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.contact_center_insights.ListConversationsResponse: - The response of listing - conversations. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*}/conversations', - }, - ] - request, metadata = self._interceptor.pre_list_conversations(request, metadata) - pb_request = contact_center_insights.ListConversationsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = contact_center_insights.ListConversationsResponse() - pb_resp = contact_center_insights.ListConversationsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_conversations(resp) - return resp - - class _ListIssueModels(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("ListIssueModels") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.ListIssueModelsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> contact_center_insights.ListIssueModelsResponse: - r"""Call the list issue models method over HTTP. - - Args: - request (~.contact_center_insights.ListIssueModelsRequest): - The request object. Request to list issue models. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.contact_center_insights.ListIssueModelsResponse: - The response of listing issue models. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*}/issueModels', - }, - ] - request, metadata = self._interceptor.pre_list_issue_models(request, metadata) - pb_request = contact_center_insights.ListIssueModelsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = contact_center_insights.ListIssueModelsResponse() - pb_resp = contact_center_insights.ListIssueModelsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_issue_models(resp) - return resp - - class _ListIssues(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("ListIssues") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.ListIssuesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> contact_center_insights.ListIssuesResponse: - r"""Call the list issues method over HTTP. - - Args: - request (~.contact_center_insights.ListIssuesRequest): - The request object. Request to list issues. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.contact_center_insights.ListIssuesResponse: - The response of listing issues. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*/issueModels/*}/issues', - }, - ] - request, metadata = self._interceptor.pre_list_issues(request, metadata) - pb_request = contact_center_insights.ListIssuesRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = contact_center_insights.ListIssuesResponse() - pb_resp = contact_center_insights.ListIssuesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_issues(resp) - return resp - - class _ListPhraseMatchers(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("ListPhraseMatchers") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.ListPhraseMatchersRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> contact_center_insights.ListPhraseMatchersResponse: - r"""Call the list phrase matchers method over HTTP. - - Args: - request (~.contact_center_insights.ListPhraseMatchersRequest): - The request object. Request to list phrase matchers. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.contact_center_insights.ListPhraseMatchersResponse: - The response of listing phrase - matchers. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*}/phraseMatchers', - }, - ] - request, metadata = self._interceptor.pre_list_phrase_matchers(request, metadata) - pb_request = contact_center_insights.ListPhraseMatchersRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = contact_center_insights.ListPhraseMatchersResponse() - pb_resp = contact_center_insights.ListPhraseMatchersResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_phrase_matchers(resp) - return resp - - class _ListViews(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("ListViews") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.ListViewsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> contact_center_insights.ListViewsResponse: - r"""Call the list views method over HTTP. - - Args: - request (~.contact_center_insights.ListViewsRequest): - The request object. The request to list views. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.contact_center_insights.ListViewsResponse: - The response of listing views. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*}/views', - }, - ] - request, metadata = self._interceptor.pre_list_views(request, metadata) - pb_request = contact_center_insights.ListViewsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = contact_center_insights.ListViewsResponse() - pb_resp = contact_center_insights.ListViewsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_views(resp) - return resp - - class _UndeployIssueModel(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("UndeployIssueModel") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.UndeployIssueModelRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the undeploy issue model method over HTTP. - - Args: - request (~.contact_center_insights.UndeployIssueModelRequest): - The request object. The request to undeploy an issue - model. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{name=projects/*/locations/*/issueModels/*}:undeploy', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_undeploy_issue_model(request, metadata) - pb_request = contact_center_insights.UndeployIssueModelRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_undeploy_issue_model(resp) - return resp - - class _UpdateConversation(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("UpdateConversation") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.UpdateConversationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> resources.Conversation: - r"""Call the update conversation method over HTTP. - - Args: - request (~.contact_center_insights.UpdateConversationRequest): - The request object. The request to update a conversation. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.resources.Conversation: - The conversation resource. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{conversation.name=projects/*/locations/*/conversations/*}', - 'body': 'conversation', - }, - ] - request, metadata = self._interceptor.pre_update_conversation(request, metadata) - pb_request = contact_center_insights.UpdateConversationRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = resources.Conversation() - pb_resp = resources.Conversation.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_conversation(resp) - return resp - - class _UpdateIssue(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("UpdateIssue") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.UpdateIssueRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> resources.Issue: - r"""Call the update issue method over HTTP. - - Args: - request (~.contact_center_insights.UpdateIssueRequest): - The request object. The request to update an issue. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.resources.Issue: - The issue resource. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{issue.name=projects/*/locations/*/issueModels/*/issues/*}', - 'body': 'issue', - }, - ] - request, metadata = self._interceptor.pre_update_issue(request, metadata) - pb_request = contact_center_insights.UpdateIssueRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = resources.Issue() - pb_resp = resources.Issue.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_issue(resp) - return resp - - class _UpdateIssueModel(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("UpdateIssueModel") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.UpdateIssueModelRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> resources.IssueModel: - r"""Call the update issue model method over HTTP. - - Args: - request (~.contact_center_insights.UpdateIssueModelRequest): - The request object. The request to update an issue model. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.resources.IssueModel: - The issue model resource. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{issue_model.name=projects/*/locations/*/issueModels/*}', - 'body': 'issue_model', - }, - ] - request, metadata = self._interceptor.pre_update_issue_model(request, metadata) - pb_request = contact_center_insights.UpdateIssueModelRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = resources.IssueModel() - pb_resp = resources.IssueModel.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_issue_model(resp) - return resp - - class _UpdatePhraseMatcher(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("UpdatePhraseMatcher") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.UpdatePhraseMatcherRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> resources.PhraseMatcher: - r"""Call the update phrase matcher method over HTTP. - - Args: - request (~.contact_center_insights.UpdatePhraseMatcherRequest): - The request object. The request to update a phrase - matcher. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.resources.PhraseMatcher: - The phrase matcher resource. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{phrase_matcher.name=projects/*/locations/*/phraseMatchers/*}', - 'body': 'phrase_matcher', - }, - ] - request, metadata = self._interceptor.pre_update_phrase_matcher(request, metadata) - pb_request = contact_center_insights.UpdatePhraseMatcherRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = resources.PhraseMatcher() - pb_resp = resources.PhraseMatcher.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_phrase_matcher(resp) - return resp - - class _UpdateSettings(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("UpdateSettings") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "updateMask" : {}, } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.UpdateSettingsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> resources.Settings: - r"""Call the update settings method over HTTP. - - Args: - request (~.contact_center_insights.UpdateSettingsRequest): - The request object. The request to update project-level - settings. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.resources.Settings: - The settings resource. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{settings.name=projects/*/locations/*/settings}', - 'body': 'settings', - }, - ] - request, metadata = self._interceptor.pre_update_settings(request, metadata) - pb_request = contact_center_insights.UpdateSettingsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = resources.Settings() - pb_resp = resources.Settings.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_settings(resp) - return resp - - class _UpdateView(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("UpdateView") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.UpdateViewRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> resources.View: - r"""Call the update view method over HTTP. - - Args: - request (~.contact_center_insights.UpdateViewRequest): - The request object. The request to update a view. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.resources.View: - The View resource. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{view.name=projects/*/locations/*/views/*}', - 'body': 'view', - }, - ] - request, metadata = self._interceptor.pre_update_view(request, metadata) - pb_request = contact_center_insights.UpdateViewRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = resources.View() - pb_resp = resources.View.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_view(resp) - return resp - - class _UploadConversation(ContactCenterInsightsRestStub): - def __hash__(self): - return hash("UploadConversation") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: contact_center_insights.UploadConversationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the upload conversation method over HTTP. - - Args: - request (~.contact_center_insights.UploadConversationRequest): - The request object. Request to upload a conversation. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/conversations:upload', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_upload_conversation(request, metadata) - pb_request = contact_center_insights.UploadConversationRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_upload_conversation(resp) - return resp - - @property - def bulk_analyze_conversations(self) -> Callable[ - [contact_center_insights.BulkAnalyzeConversationsRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._BulkAnalyzeConversations(self._session, self._host, self._interceptor) # type: ignore - - @property - def calculate_issue_model_stats(self) -> Callable[ - [contact_center_insights.CalculateIssueModelStatsRequest], - contact_center_insights.CalculateIssueModelStatsResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._CalculateIssueModelStats(self._session, self._host, self._interceptor) # type: ignore - - @property - def calculate_stats(self) -> Callable[ - [contact_center_insights.CalculateStatsRequest], - contact_center_insights.CalculateStatsResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._CalculateStats(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_analysis(self) -> Callable[ - [contact_center_insights.CreateAnalysisRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._CreateAnalysis(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_conversation(self) -> Callable[ - [contact_center_insights.CreateConversationRequest], - resources.Conversation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._CreateConversation(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_issue_model(self) -> Callable[ - [contact_center_insights.CreateIssueModelRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._CreateIssueModel(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_phrase_matcher(self) -> Callable[ - [contact_center_insights.CreatePhraseMatcherRequest], - resources.PhraseMatcher]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._CreatePhraseMatcher(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_view(self) -> Callable[ - [contact_center_insights.CreateViewRequest], - resources.View]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._CreateView(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_analysis(self) -> Callable[ - [contact_center_insights.DeleteAnalysisRequest], - empty_pb2.Empty]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._DeleteAnalysis(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_conversation(self) -> Callable[ - [contact_center_insights.DeleteConversationRequest], - empty_pb2.Empty]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._DeleteConversation(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_issue(self) -> Callable[ - [contact_center_insights.DeleteIssueRequest], - empty_pb2.Empty]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._DeleteIssue(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_issue_model(self) -> Callable[ - [contact_center_insights.DeleteIssueModelRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._DeleteIssueModel(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_phrase_matcher(self) -> Callable[ - [contact_center_insights.DeletePhraseMatcherRequest], - empty_pb2.Empty]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._DeletePhraseMatcher(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_view(self) -> Callable[ - [contact_center_insights.DeleteViewRequest], - empty_pb2.Empty]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._DeleteView(self._session, self._host, self._interceptor) # type: ignore - - @property - def deploy_issue_model(self) -> Callable[ - [contact_center_insights.DeployIssueModelRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._DeployIssueModel(self._session, self._host, self._interceptor) # type: ignore - - @property - def export_insights_data(self) -> Callable[ - [contact_center_insights.ExportInsightsDataRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ExportInsightsData(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_analysis(self) -> Callable[ - [contact_center_insights.GetAnalysisRequest], - resources.Analysis]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetAnalysis(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_conversation(self) -> Callable[ - [contact_center_insights.GetConversationRequest], - resources.Conversation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetConversation(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_issue(self) -> Callable[ - [contact_center_insights.GetIssueRequest], - resources.Issue]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetIssue(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_issue_model(self) -> Callable[ - [contact_center_insights.GetIssueModelRequest], - resources.IssueModel]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetIssueModel(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_phrase_matcher(self) -> Callable[ - [contact_center_insights.GetPhraseMatcherRequest], - resources.PhraseMatcher]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetPhraseMatcher(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_settings(self) -> Callable[ - [contact_center_insights.GetSettingsRequest], - resources.Settings]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetSettings(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_view(self) -> Callable[ - [contact_center_insights.GetViewRequest], - resources.View]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetView(self._session, self._host, self._interceptor) # type: ignore - - @property - def ingest_conversations(self) -> Callable[ - [contact_center_insights.IngestConversationsRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._IngestConversations(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_analyses(self) -> Callable[ - [contact_center_insights.ListAnalysesRequest], - contact_center_insights.ListAnalysesResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListAnalyses(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_conversations(self) -> Callable[ - [contact_center_insights.ListConversationsRequest], - contact_center_insights.ListConversationsResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListConversations(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_issue_models(self) -> Callable[ - [contact_center_insights.ListIssueModelsRequest], - contact_center_insights.ListIssueModelsResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListIssueModels(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_issues(self) -> Callable[ - [contact_center_insights.ListIssuesRequest], - contact_center_insights.ListIssuesResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListIssues(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_phrase_matchers(self) -> Callable[ - [contact_center_insights.ListPhraseMatchersRequest], - contact_center_insights.ListPhraseMatchersResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListPhraseMatchers(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_views(self) -> Callable[ - [contact_center_insights.ListViewsRequest], - contact_center_insights.ListViewsResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListViews(self._session, self._host, self._interceptor) # type: ignore - - @property - def undeploy_issue_model(self) -> Callable[ - [contact_center_insights.UndeployIssueModelRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._UndeployIssueModel(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_conversation(self) -> Callable[ - [contact_center_insights.UpdateConversationRequest], - resources.Conversation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._UpdateConversation(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_issue(self) -> Callable[ - [contact_center_insights.UpdateIssueRequest], - resources.Issue]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._UpdateIssue(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_issue_model(self) -> Callable[ - [contact_center_insights.UpdateIssueModelRequest], - resources.IssueModel]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._UpdateIssueModel(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_phrase_matcher(self) -> Callable[ - [contact_center_insights.UpdatePhraseMatcherRequest], - resources.PhraseMatcher]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._UpdatePhraseMatcher(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_settings(self) -> Callable[ - [contact_center_insights.UpdateSettingsRequest], - resources.Settings]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._UpdateSettings(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_view(self) -> Callable[ - [contact_center_insights.UpdateViewRequest], - resources.View]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._UpdateView(self._session, self._host, self._interceptor) # type: ignore - - @property - def upload_conversation(self) -> Callable[ - [contact_center_insights.UploadConversationRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._UploadConversation(self._session, self._host, self._interceptor) # type: ignore - - @property - def cancel_operation(self): - return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore - - class _CancelOperation(ContactCenterInsightsRestStub): - def __call__(self, - request: operations_pb2.CancelOperationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> None: - - r"""Call the cancel operation method over HTTP. - - Args: - request (operations_pb2.CancelOperationRequest): - The request object for CancelOperation method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{name=projects/*/locations/*/operations/*}:cancel', - }, - ] - - request, metadata = self._interceptor.pre_cancel_operation(request, metadata) - request_kwargs = json_format.MessageToDict(request) - transcoded_request = path_template.transcode( - http_options, **request_kwargs) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json.dumps(transcoded_request['query_params'])) - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - return self._interceptor.post_cancel_operation(None) - - @property - def get_operation(self): - return self._GetOperation(self._session, self._host, self._interceptor) # type: ignore - - class _GetOperation(ContactCenterInsightsRestStub): - def __call__(self, - request: operations_pb2.GetOperationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - - r"""Call the get operation method over HTTP. - - Args: - request (operations_pb2.GetOperationRequest): - The request object for GetOperation method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - operations_pb2.Operation: Response from GetOperation method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/operations/*}', - }, - ] - - request, metadata = self._interceptor.pre_get_operation(request, metadata) - request_kwargs = json_format.MessageToDict(request) - transcoded_request = path_template.transcode( - http_options, **request_kwargs) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json.dumps(transcoded_request['query_params'])) - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - resp = operations_pb2.Operation() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_get_operation(resp) - return resp - - @property - def list_operations(self): - return self._ListOperations(self._session, self._host, self._interceptor) # type: ignore - - class _ListOperations(ContactCenterInsightsRestStub): - def __call__(self, - request: operations_pb2.ListOperationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.ListOperationsResponse: - - r"""Call the list operations method over HTTP. - - Args: - request (operations_pb2.ListOperationsRequest): - The request object for ListOperations method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - operations_pb2.ListOperationsResponse: Response from ListOperations method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*}/operations', - }, - ] - - request, metadata = self._interceptor.pre_list_operations(request, metadata) - request_kwargs = json_format.MessageToDict(request) - transcoded_request = path_template.transcode( - http_options, **request_kwargs) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json.dumps(transcoded_request['query_params'])) - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - resp = operations_pb2.ListOperationsResponse() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_list_operations(resp) - return resp - - @property - def kind(self) -> str: - return "rest" - - def close(self): - self._session.close() - - -__all__=( - 'ContactCenterInsightsRestTransport', -) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/__init__.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/__init__.py deleted file mode 100644 index 56f174a104a2..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/__init__.py +++ /dev/null @@ -1,232 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -from .contact_center_insights import ( - BulkAnalyzeConversationsMetadata, - BulkAnalyzeConversationsRequest, - BulkAnalyzeConversationsResponse, - CalculateIssueModelStatsRequest, - CalculateIssueModelStatsResponse, - CalculateStatsRequest, - CalculateStatsResponse, - CreateAnalysisOperationMetadata, - CreateAnalysisRequest, - CreateConversationRequest, - CreateIssueModelMetadata, - CreateIssueModelRequest, - CreatePhraseMatcherRequest, - CreateViewRequest, - DeleteAnalysisRequest, - DeleteConversationRequest, - DeleteIssueModelMetadata, - DeleteIssueModelRequest, - DeleteIssueRequest, - DeletePhraseMatcherRequest, - DeleteViewRequest, - DeployIssueModelMetadata, - DeployIssueModelRequest, - DeployIssueModelResponse, - ExportInsightsDataMetadata, - ExportInsightsDataRequest, - ExportInsightsDataResponse, - GetAnalysisRequest, - GetConversationRequest, - GetIssueModelRequest, - GetIssueRequest, - GetPhraseMatcherRequest, - GetSettingsRequest, - GetViewRequest, - IngestConversationsMetadata, - IngestConversationsRequest, - IngestConversationsResponse, - ListAnalysesRequest, - ListAnalysesResponse, - ListConversationsRequest, - ListConversationsResponse, - ListIssueModelsRequest, - ListIssueModelsResponse, - ListIssuesRequest, - ListIssuesResponse, - ListPhraseMatchersRequest, - ListPhraseMatchersResponse, - ListViewsRequest, - ListViewsResponse, - UndeployIssueModelMetadata, - UndeployIssueModelRequest, - UndeployIssueModelResponse, - UpdateConversationRequest, - UpdateIssueModelRequest, - UpdateIssueRequest, - UpdatePhraseMatcherRequest, - UpdateSettingsRequest, - UpdateViewRequest, - UploadConversationMetadata, - UploadConversationRequest, - ConversationView, -) -from .resources import ( - Analysis, - AnalysisResult, - AnnotationBoundary, - AnnotatorSelector, - AnswerFeedback, - ArticleSuggestionData, - CallAnnotation, - Conversation, - ConversationDataSource, - ConversationLevelSentiment, - ConversationParticipant, - ConversationSummarizationSuggestionData, - DialogflowIntent, - DialogflowInteractionData, - DialogflowSource, - Entity, - EntityMentionData, - ExactMatchConfig, - FaqAnswerData, - GcsSource, - HoldData, - Intent, - IntentMatchData, - InterruptionData, - Issue, - IssueAssignment, - IssueMatchData, - IssueModel, - IssueModelLabelStats, - IssueModelResult, - PhraseMatchData, - PhraseMatcher, - PhraseMatchRule, - PhraseMatchRuleConfig, - PhraseMatchRuleGroup, - RedactionConfig, - RuntimeAnnotation, - SentimentData, - Settings, - SilenceData, - SmartComposeSuggestionData, - SmartReplyData, - SpeechConfig, - View, -) - -__all__ = ( - 'BulkAnalyzeConversationsMetadata', - 'BulkAnalyzeConversationsRequest', - 'BulkAnalyzeConversationsResponse', - 'CalculateIssueModelStatsRequest', - 'CalculateIssueModelStatsResponse', - 'CalculateStatsRequest', - 'CalculateStatsResponse', - 'CreateAnalysisOperationMetadata', - 'CreateAnalysisRequest', - 'CreateConversationRequest', - 'CreateIssueModelMetadata', - 'CreateIssueModelRequest', - 'CreatePhraseMatcherRequest', - 'CreateViewRequest', - 'DeleteAnalysisRequest', - 'DeleteConversationRequest', - 'DeleteIssueModelMetadata', - 'DeleteIssueModelRequest', - 'DeleteIssueRequest', - 'DeletePhraseMatcherRequest', - 'DeleteViewRequest', - 'DeployIssueModelMetadata', - 'DeployIssueModelRequest', - 'DeployIssueModelResponse', - 'ExportInsightsDataMetadata', - 'ExportInsightsDataRequest', - 'ExportInsightsDataResponse', - 'GetAnalysisRequest', - 'GetConversationRequest', - 'GetIssueModelRequest', - 'GetIssueRequest', - 'GetPhraseMatcherRequest', - 'GetSettingsRequest', - 'GetViewRequest', - 'IngestConversationsMetadata', - 'IngestConversationsRequest', - 'IngestConversationsResponse', - 'ListAnalysesRequest', - 'ListAnalysesResponse', - 'ListConversationsRequest', - 'ListConversationsResponse', - 'ListIssueModelsRequest', - 'ListIssueModelsResponse', - 'ListIssuesRequest', - 'ListIssuesResponse', - 'ListPhraseMatchersRequest', - 'ListPhraseMatchersResponse', - 'ListViewsRequest', - 'ListViewsResponse', - 'UndeployIssueModelMetadata', - 'UndeployIssueModelRequest', - 'UndeployIssueModelResponse', - 'UpdateConversationRequest', - 'UpdateIssueModelRequest', - 'UpdateIssueRequest', - 'UpdatePhraseMatcherRequest', - 'UpdateSettingsRequest', - 'UpdateViewRequest', - 'UploadConversationMetadata', - 'UploadConversationRequest', - 'ConversationView', - 'Analysis', - 'AnalysisResult', - 'AnnotationBoundary', - 'AnnotatorSelector', - 'AnswerFeedback', - 'ArticleSuggestionData', - 'CallAnnotation', - 'Conversation', - 'ConversationDataSource', - 'ConversationLevelSentiment', - 'ConversationParticipant', - 'ConversationSummarizationSuggestionData', - 'DialogflowIntent', - 'DialogflowInteractionData', - 'DialogflowSource', - 'Entity', - 'EntityMentionData', - 'ExactMatchConfig', - 'FaqAnswerData', - 'GcsSource', - 'HoldData', - 'Intent', - 'IntentMatchData', - 'InterruptionData', - 'Issue', - 'IssueAssignment', - 'IssueMatchData', - 'IssueModel', - 'IssueModelLabelStats', - 'IssueModelResult', - 'PhraseMatchData', - 'PhraseMatcher', - 'PhraseMatchRule', - 'PhraseMatchRuleConfig', - 'PhraseMatchRuleGroup', - 'RedactionConfig', - 'RuntimeAnnotation', - 'SentimentData', - 'Settings', - 'SilenceData', - 'SmartComposeSuggestionData', - 'SmartReplyData', - 'SpeechConfig', - 'View', -) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/contact_center_insights.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/contact_center_insights.py deleted file mode 100644 index 4e9c11a12f05..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/contact_center_insights.py +++ /dev/null @@ -1,1838 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -from __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.cloud.contact_center_insights_v1.types import resources -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from google.rpc import status_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.contactcenterinsights.v1', - manifest={ - 'ConversationView', - 'CalculateStatsRequest', - 'CalculateStatsResponse', - 'CreateAnalysisOperationMetadata', - 'CreateConversationRequest', - 'UploadConversationRequest', - 'UploadConversationMetadata', - 'ListConversationsRequest', - 'ListConversationsResponse', - 'GetConversationRequest', - 'UpdateConversationRequest', - 'DeleteConversationRequest', - 'IngestConversationsRequest', - 'IngestConversationsMetadata', - 'IngestConversationsResponse', - 'CreateAnalysisRequest', - 'ListAnalysesRequest', - 'ListAnalysesResponse', - 'GetAnalysisRequest', - 'DeleteAnalysisRequest', - 'BulkAnalyzeConversationsRequest', - 'BulkAnalyzeConversationsMetadata', - 'BulkAnalyzeConversationsResponse', - 'ExportInsightsDataRequest', - 'ExportInsightsDataMetadata', - 'ExportInsightsDataResponse', - 'CreateIssueModelRequest', - 'CreateIssueModelMetadata', - 'UpdateIssueModelRequest', - 'ListIssueModelsRequest', - 'ListIssueModelsResponse', - 'GetIssueModelRequest', - 'DeleteIssueModelRequest', - 'DeleteIssueModelMetadata', - 'DeployIssueModelRequest', - 'DeployIssueModelResponse', - 'DeployIssueModelMetadata', - 'UndeployIssueModelRequest', - 'UndeployIssueModelResponse', - 'UndeployIssueModelMetadata', - 'GetIssueRequest', - 'ListIssuesRequest', - 'ListIssuesResponse', - 'UpdateIssueRequest', - 'DeleteIssueRequest', - 'CalculateIssueModelStatsRequest', - 'CalculateIssueModelStatsResponse', - 'CreatePhraseMatcherRequest', - 'ListPhraseMatchersRequest', - 'ListPhraseMatchersResponse', - 'GetPhraseMatcherRequest', - 'DeletePhraseMatcherRequest', - 'UpdatePhraseMatcherRequest', - 'GetSettingsRequest', - 'UpdateSettingsRequest', - 'CreateViewRequest', - 'GetViewRequest', - 'ListViewsRequest', - 'ListViewsResponse', - 'UpdateViewRequest', - 'DeleteViewRequest', - }, -) - - -class ConversationView(proto.Enum): - r"""Represents the options for viewing a conversation. - - Values: - CONVERSATION_VIEW_UNSPECIFIED (0): - The conversation view is not specified. - - - Defaults to ``FULL`` in ``GetConversationRequest``. - - Defaults to ``BASIC`` in ``ListConversationsRequest``. - FULL (2): - Populates all fields in the conversation. - BASIC (1): - Populates all fields in the conversation - except the transcript. - """ - CONVERSATION_VIEW_UNSPECIFIED = 0 - FULL = 2 - BASIC = 1 - - -class CalculateStatsRequest(proto.Message): - r"""The request for calculating conversation statistics. - - Attributes: - location (str): - Required. The location of the conversations. - filter (str): - A filter to reduce results to a specific - subset. This field is useful for getting - statistics about conversations with specific - properties. - """ - - location: str = proto.Field( - proto.STRING, - number=1, - ) - filter: str = proto.Field( - proto.STRING, - number=2, - ) - - -class CalculateStatsResponse(proto.Message): - r"""The response for calculating conversation statistics. - - Attributes: - average_duration (google.protobuf.duration_pb2.Duration): - The average duration of all conversations. - The average is calculated using only - conversations that have a time duration. - average_turn_count (int): - The average number of turns per conversation. - conversation_count (int): - The total number of conversations. - smart_highlighter_matches (MutableMapping[str, int]): - A map associating each smart highlighter - display name with its respective number of - matches in the set of conversations. - custom_highlighter_matches (MutableMapping[str, int]): - A map associating each custom highlighter - resource name with its respective number of - matches in the set of conversations. - issue_matches (MutableMapping[str, int]): - A map associating each issue resource name with its - respective number of matches in the set of conversations. - Key has the format: - ``projects//locations//issueModels//issues/`` - Deprecated, use ``issue_matches_stats`` field instead. - issue_matches_stats (MutableMapping[str, google.cloud.contact_center_insights_v1.types.IssueModelLabelStats.IssueStats]): - A map associating each issue resource name with its - respective number of matches in the set of conversations. - Key has the format: - ``projects//locations//issueModels//issues/`` - conversation_count_time_series (google.cloud.contact_center_insights_v1.types.CalculateStatsResponse.TimeSeries): - A time series representing the count of - conversations created over time that match that - requested filter criteria. - """ - - class TimeSeries(proto.Message): - r"""A time series representing conversations over time. - - Attributes: - interval_duration (google.protobuf.duration_pb2.Duration): - The duration of each interval. - points (MutableSequence[google.cloud.contact_center_insights_v1.types.CalculateStatsResponse.TimeSeries.Interval]): - An ordered list of intervals from earliest to - latest, where each interval represents the - number of conversations that transpired during - the time window. - """ - - class Interval(proto.Message): - r"""A single interval in a time series. - - Attributes: - start_time (google.protobuf.timestamp_pb2.Timestamp): - The start time of this interval. - conversation_count (int): - The number of conversations created in this - interval. - """ - - start_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - conversation_count: int = proto.Field( - proto.INT32, - number=2, - ) - - interval_duration: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=1, - message=duration_pb2.Duration, - ) - points: MutableSequence['CalculateStatsResponse.TimeSeries.Interval'] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='CalculateStatsResponse.TimeSeries.Interval', - ) - - average_duration: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=1, - message=duration_pb2.Duration, - ) - average_turn_count: int = proto.Field( - proto.INT32, - number=2, - ) - conversation_count: int = proto.Field( - proto.INT32, - number=3, - ) - smart_highlighter_matches: MutableMapping[str, int] = proto.MapField( - proto.STRING, - proto.INT32, - number=4, - ) - custom_highlighter_matches: MutableMapping[str, int] = proto.MapField( - proto.STRING, - proto.INT32, - number=5, - ) - issue_matches: MutableMapping[str, int] = proto.MapField( - proto.STRING, - proto.INT32, - number=6, - ) - issue_matches_stats: MutableMapping[str, resources.IssueModelLabelStats.IssueStats] = proto.MapField( - proto.STRING, - proto.MESSAGE, - number=8, - message=resources.IssueModelLabelStats.IssueStats, - ) - conversation_count_time_series: TimeSeries = proto.Field( - proto.MESSAGE, - number=7, - message=TimeSeries, - ) - - -class CreateAnalysisOperationMetadata(proto.Message): - r"""Metadata for a create analysis operation. - - Attributes: - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation was - created. - end_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation finished - running. - conversation (str): - Output only. The Conversation that this - Analysis Operation belongs to. - annotator_selector (google.cloud.contact_center_insights_v1.types.AnnotatorSelector): - Output only. The annotator selector used for - the analysis (if any). - """ - - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - conversation: str = proto.Field( - proto.STRING, - number=3, - ) - annotator_selector: resources.AnnotatorSelector = proto.Field( - proto.MESSAGE, - number=4, - message=resources.AnnotatorSelector, - ) - - -class CreateConversationRequest(proto.Message): - r"""Request to create a conversation. - - Attributes: - parent (str): - Required. The parent resource of the - conversation. - conversation (google.cloud.contact_center_insights_v1.types.Conversation): - Required. The conversation resource to - create. - conversation_id (str): - A unique ID for the new conversation. This ID will become - the final component of the conversation's resource name. If - no ID is specified, a server-generated ID will be used. - - This value should be 4-64 characters and must match the - regular expression ``^[a-z0-9-]{4,64}$``. Valid characters - are ``[a-z][0-9]-`` - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - conversation: resources.Conversation = proto.Field( - proto.MESSAGE, - number=2, - message=resources.Conversation, - ) - conversation_id: str = proto.Field( - proto.STRING, - number=3, - ) - - -class UploadConversationRequest(proto.Message): - r"""Request to upload a conversation. - - Attributes: - parent (str): - Required. The parent resource of the - conversation. - conversation (google.cloud.contact_center_insights_v1.types.Conversation): - Required. The conversation resource to - create. - conversation_id (str): - Optional. A unique ID for the new conversation. This ID will - become the final component of the conversation's resource - name. If no ID is specified, a server-generated ID will be - used. - - This value should be 4-64 characters and must match the - regular expression ``^[a-z0-9-]{4,64}$``. Valid characters - are ``[a-z][0-9]-`` - redaction_config (google.cloud.contact_center_insights_v1.types.RedactionConfig): - 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( - proto.STRING, - number=1, - ) - conversation: resources.Conversation = proto.Field( - proto.MESSAGE, - number=2, - message=resources.Conversation, - ) - conversation_id: str = proto.Field( - proto.STRING, - number=3, - ) - redaction_config: resources.RedactionConfig = proto.Field( - proto.MESSAGE, - number=4, - message=resources.RedactionConfig, - ) - speech_config: resources.SpeechConfig = proto.Field( - proto.MESSAGE, - number=11, - message=resources.SpeechConfig, - ) - - -class UploadConversationMetadata(proto.Message): - r"""The metadata for an UploadConversation operation. - - Attributes: - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation was - created. - end_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation finished - running. - request (google.cloud.contact_center_insights_v1.types.UploadConversationRequest): - Output only. The original request. - analysis_operation (str): - Output only. The operation name for a - successfully created analysis operation, if any. - applied_redaction_config (google.cloud.contact_center_insights_v1.types.RedactionConfig): - Output only. The redaction config applied to - the uploaded conversation. - """ - - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - request: 'UploadConversationRequest' = proto.Field( - proto.MESSAGE, - number=3, - message='UploadConversationRequest', - ) - analysis_operation: str = proto.Field( - proto.STRING, - number=4, - ) - applied_redaction_config: resources.RedactionConfig = proto.Field( - proto.MESSAGE, - number=5, - message=resources.RedactionConfig, - ) - - -class ListConversationsRequest(proto.Message): - r"""Request to list conversations. - - Attributes: - parent (str): - Required. The parent resource of the - conversation. - page_size (int): - The maximum number of conversations to return - in the response. A valid page size ranges from 0 - to 1,000 inclusive. If the page size is zero or - unspecified, a default page size of 100 will be - chosen. Note that a call might return fewer - results than the requested page size. - page_token (str): - The value returned by the last - ``ListConversationsResponse``. This value indicates that - this is a continuation of a prior ``ListConversations`` call - and that the system should return the next page of data. - filter (str): - A filter to reduce results to a specific - subset. Useful for querying conversations with - specific properties. - view (google.cloud.contact_center_insights_v1.types.ConversationView): - The level of details of the conversation. Default is - ``BASIC``. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - page_size: int = proto.Field( - proto.INT32, - number=2, - ) - page_token: str = proto.Field( - proto.STRING, - number=3, - ) - filter: str = proto.Field( - proto.STRING, - number=4, - ) - view: 'ConversationView' = proto.Field( - proto.ENUM, - number=5, - enum='ConversationView', - ) - - -class ListConversationsResponse(proto.Message): - r"""The response of listing conversations. - - Attributes: - conversations (MutableSequence[google.cloud.contact_center_insights_v1.types.Conversation]): - The conversations that match the request. - next_page_token (str): - A token which can be sent as ``page_token`` to retrieve the - next page. If this field is set, it means there is another - page available. If it is not set, it means no other pages - are available. - """ - - @property - def raw_page(self): - return self - - conversations: MutableSequence[resources.Conversation] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=resources.Conversation, - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetConversationRequest(proto.Message): - r"""The request to get a conversation. - - Attributes: - name (str): - Required. The name of the conversation to - get. - view (google.cloud.contact_center_insights_v1.types.ConversationView): - The level of details of the conversation. Default is - ``FULL``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - view: 'ConversationView' = proto.Field( - proto.ENUM, - number=2, - enum='ConversationView', - ) - - -class UpdateConversationRequest(proto.Message): - r"""The request to update a conversation. - - Attributes: - conversation (google.cloud.contact_center_insights_v1.types.Conversation): - Required. The new values for the - conversation. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The list of fields to be updated. - """ - - conversation: resources.Conversation = proto.Field( - proto.MESSAGE, - number=1, - message=resources.Conversation, - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteConversationRequest(proto.Message): - r"""The request to delete a conversation. - - Attributes: - name (str): - Required. The name of the conversation to - delete. - force (bool): - If set to true, all of this conversation's - analyses will also be deleted. Otherwise, the - request will only succeed if the conversation - has no analyses. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - force: bool = proto.Field( - proto.BOOL, - number=2, - ) - - -class IngestConversationsRequest(proto.Message): - r"""The request to ingest conversations. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - gcs_source (google.cloud.contact_center_insights_v1.types.IngestConversationsRequest.GcsSource): - 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): - Configuration for when ``source`` contains conversation - transcripts. - - This field is a member of `oneof`_ ``object_config``. - parent (str): - Required. The parent resource for new - conversations. - conversation_config (google.cloud.contact_center_insights_v1.types.IngestConversationsRequest.ConversationConfig): - Configuration that applies to all - conversations. - """ - - class GcsSource(proto.Message): - r"""Configuration for Cloud Storage bucket sources. - - Attributes: - bucket_uri (str): - Required. The Cloud Storage bucket containing - source objects. - """ - - bucket_uri: str = proto.Field( - proto.STRING, - number=1, - ) - - class TranscriptObjectConfig(proto.Message): - r"""Configuration for processing transcript objects. - - Attributes: - medium (google.cloud.contact_center_insights_v1.types.Conversation.Medium): - Required. The medium transcript objects - represent. - """ - - medium: resources.Conversation.Medium = proto.Field( - proto.ENUM, - number=1, - enum=resources.Conversation.Medium, - ) - - class ConversationConfig(proto.Message): - r"""Configuration that applies to all conversations. - - Attributes: - agent_id (str): - An opaque, user-specified string representing - the human agent who handled the conversations. - """ - - agent_id: str = proto.Field( - proto.STRING, - number=1, - ) - - gcs_source: GcsSource = proto.Field( - proto.MESSAGE, - number=2, - oneof='source', - message=GcsSource, - ) - transcript_object_config: TranscriptObjectConfig = proto.Field( - proto.MESSAGE, - number=3, - oneof='object_config', - message=TranscriptObjectConfig, - ) - parent: str = proto.Field( - proto.STRING, - number=1, - ) - conversation_config: ConversationConfig = proto.Field( - proto.MESSAGE, - number=4, - message=ConversationConfig, - ) - - -class IngestConversationsMetadata(proto.Message): - r"""The metadata for an IngestConversations operation. - - Attributes: - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation was - created. - end_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation finished - running. - request (google.cloud.contact_center_insights_v1.types.IngestConversationsRequest): - Output only. The original request for ingest. - partial_errors (MutableSequence[google.rpc.status_pb2.Status]): - Output only. Partial errors during ingest - operation that might cause the operation output - to be incomplete. - ingest_conversations_stats (google.cloud.contact_center_insights_v1.types.IngestConversationsMetadata.IngestConversationsStats): - Output only. Statistics for - IngestConversations operation. - """ - - class IngestConversationsStats(proto.Message): - r"""Statistics for IngestConversations operation. - - Attributes: - processed_object_count (int): - Output only. The number of objects processed - during the ingest operation. - duplicates_skipped_count (int): - Output only. The number of objects skipped - because another conversation with the same - transcript uri had already been ingested. - successful_ingest_count (int): - Output only. The number of new conversations - added during this ingest operation. - failed_ingest_count (int): - Output only. The number of objects which were unable to be - ingested due to errors. The errors are populated in the - partial_errors field. - """ - - processed_object_count: int = proto.Field( - proto.INT32, - number=1, - ) - duplicates_skipped_count: int = proto.Field( - proto.INT32, - number=2, - ) - successful_ingest_count: int = proto.Field( - proto.INT32, - number=3, - ) - failed_ingest_count: int = proto.Field( - proto.INT32, - number=4, - ) - - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - request: 'IngestConversationsRequest' = proto.Field( - proto.MESSAGE, - number=3, - message='IngestConversationsRequest', - ) - partial_errors: MutableSequence[status_pb2.Status] = proto.RepeatedField( - proto.MESSAGE, - number=4, - message=status_pb2.Status, - ) - ingest_conversations_stats: IngestConversationsStats = proto.Field( - proto.MESSAGE, - number=5, - message=IngestConversationsStats, - ) - - -class IngestConversationsResponse(proto.Message): - r"""The response to an IngestConversations operation. - """ - - -class CreateAnalysisRequest(proto.Message): - r"""The request to create an analysis. - - Attributes: - parent (str): - Required. The parent resource of the - analysis. - analysis (google.cloud.contact_center_insights_v1.types.Analysis): - Required. The analysis to create. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - analysis: resources.Analysis = proto.Field( - proto.MESSAGE, - number=2, - message=resources.Analysis, - ) - - -class ListAnalysesRequest(proto.Message): - r"""The request to list analyses. - - Attributes: - parent (str): - Required. The parent resource of the - analyses. - page_size (int): - The maximum number of analyses to return in the response. If - this value is zero, the service will select a default size. - A call might return fewer objects than requested. A - non-empty ``next_page_token`` in the response indicates that - more data is available. - page_token (str): - The value returned by the last ``ListAnalysesResponse``; - indicates that this is a continuation of a prior - ``ListAnalyses`` call and the system should return the next - page of data. - filter (str): - A filter to reduce results to a specific - subset. Useful for querying conversations with - specific properties. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - page_size: int = proto.Field( - proto.INT32, - number=2, - ) - page_token: str = proto.Field( - proto.STRING, - number=3, - ) - filter: str = proto.Field( - proto.STRING, - number=4, - ) - - -class ListAnalysesResponse(proto.Message): - r"""The response to list analyses. - - Attributes: - analyses (MutableSequence[google.cloud.contact_center_insights_v1.types.Analysis]): - The analyses that match the request. - next_page_token (str): - A token, which can be sent as ``page_token`` to retrieve the - next page. If this field is omitted, there are no subsequent - pages. - """ - - @property - def raw_page(self): - return self - - analyses: MutableSequence[resources.Analysis] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=resources.Analysis, - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetAnalysisRequest(proto.Message): - r"""The request to get an analysis. - - Attributes: - name (str): - Required. The name of the analysis to get. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class DeleteAnalysisRequest(proto.Message): - r"""The request to delete an analysis. - - Attributes: - name (str): - Required. The name of the analysis to delete. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class BulkAnalyzeConversationsRequest(proto.Message): - r"""The request to analyze conversations in bulk. - - Attributes: - parent (str): - Required. The parent resource to create - analyses in. - filter (str): - Required. Filter used to select the subset of - conversations to analyze. - analysis_percentage (float): - Required. Percentage of selected conversation to analyze, - between [0, 100]. - annotator_selector (google.cloud.contact_center_insights_v1.types.AnnotatorSelector): - To select the annotators to run and the - phrase matchers to use (if any). If not - specified, all annotators will be run. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - filter: str = proto.Field( - proto.STRING, - number=2, - ) - analysis_percentage: float = proto.Field( - proto.FLOAT, - number=3, - ) - annotator_selector: resources.AnnotatorSelector = proto.Field( - proto.MESSAGE, - number=8, - message=resources.AnnotatorSelector, - ) - - -class BulkAnalyzeConversationsMetadata(proto.Message): - r"""The metadata for a bulk analyze conversations operation. - - Attributes: - create_time (google.protobuf.timestamp_pb2.Timestamp): - The time the operation was created. - end_time (google.protobuf.timestamp_pb2.Timestamp): - The time the operation finished running. - request (google.cloud.contact_center_insights_v1.types.BulkAnalyzeConversationsRequest): - The original request for bulk analyze. - completed_analyses_count (int): - The number of requested analyses that have - completed successfully so far. - failed_analyses_count (int): - The number of requested analyses that have - failed so far. - total_requested_analyses_count (int): - Total number of analyses requested. Computed by the number - of conversations returned by ``filter`` multiplied by - ``analysis_percentage`` in the request. - """ - - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - request: 'BulkAnalyzeConversationsRequest' = proto.Field( - proto.MESSAGE, - number=3, - message='BulkAnalyzeConversationsRequest', - ) - completed_analyses_count: int = proto.Field( - proto.INT32, - number=4, - ) - failed_analyses_count: int = proto.Field( - proto.INT32, - number=5, - ) - total_requested_analyses_count: int = proto.Field( - proto.INT32, - number=6, - ) - - -class BulkAnalyzeConversationsResponse(proto.Message): - r"""The response for a bulk analyze conversations operation. - - Attributes: - successful_analysis_count (int): - Count of successful analyses. - failed_analysis_count (int): - Count of failed analyses. - """ - - successful_analysis_count: int = proto.Field( - proto.INT32, - number=1, - ) - failed_analysis_count: int = proto.Field( - proto.INT32, - number=2, - ) - - -class ExportInsightsDataRequest(proto.Message): - r"""The request to export insights. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - big_query_destination (google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest.BigQueryDestination): - Specified if sink is a BigQuery table. - - This field is a member of `oneof`_ ``destination``. - parent (str): - Required. The parent resource to export data - from. - filter (str): - A filter to reduce results to a specific - subset. Useful for exporting conversations with - specific properties. - kms_key (str): - A fully qualified KMS key name for BigQuery - tables protected by CMEK. Format: - - projects/{project}/locations/{location}/keyRings/{keyring}/cryptoKeys/{key}/cryptoKeyVersions/{version} - write_disposition (google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest.WriteDisposition): - Options for what to do if the destination - table already exists. - """ - class WriteDisposition(proto.Enum): - r"""Specifies the action that occurs if the destination table - already exists. - - Values: - WRITE_DISPOSITION_UNSPECIFIED (0): - Write disposition is not specified. Defaults to - WRITE_TRUNCATE. - WRITE_TRUNCATE (1): - If the table already exists, BigQuery will - overwrite the table data and use the schema from - the load. - WRITE_APPEND (2): - If the table already exists, BigQuery will - append data to the table. - """ - WRITE_DISPOSITION_UNSPECIFIED = 0 - WRITE_TRUNCATE = 1 - WRITE_APPEND = 2 - - class BigQueryDestination(proto.Message): - r"""A BigQuery Table Reference. - - Attributes: - project_id (str): - A project ID or number. If specified, then - export will attempt to write data to this - project instead of the resource project. - Otherwise, the resource project will be used. - dataset (str): - Required. The name of the BigQuery dataset that the snapshot - result should be exported to. If this dataset does not - exist, the export call returns an INVALID_ARGUMENT error. - table (str): - The BigQuery table name to which the insights data should be - written. If this table does not exist, the export call - returns an INVALID_ARGUMENT error. - """ - - project_id: str = proto.Field( - proto.STRING, - number=3, - ) - dataset: str = proto.Field( - proto.STRING, - number=1, - ) - table: str = proto.Field( - proto.STRING, - number=2, - ) - - big_query_destination: BigQueryDestination = proto.Field( - proto.MESSAGE, - number=2, - oneof='destination', - message=BigQueryDestination, - ) - parent: str = proto.Field( - proto.STRING, - number=1, - ) - filter: str = proto.Field( - proto.STRING, - number=3, - ) - kms_key: str = proto.Field( - proto.STRING, - number=4, - ) - write_disposition: WriteDisposition = proto.Field( - proto.ENUM, - number=5, - enum=WriteDisposition, - ) - - -class ExportInsightsDataMetadata(proto.Message): - r"""Metadata for an export insights operation. - - Attributes: - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation was - created. - end_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation finished - running. - request (google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest): - The original request for export. - partial_errors (MutableSequence[google.rpc.status_pb2.Status]): - Partial errors during export operation that - might cause the operation output to be - incomplete. - """ - - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - request: 'ExportInsightsDataRequest' = proto.Field( - proto.MESSAGE, - number=3, - message='ExportInsightsDataRequest', - ) - partial_errors: MutableSequence[status_pb2.Status] = proto.RepeatedField( - proto.MESSAGE, - number=4, - message=status_pb2.Status, - ) - - -class ExportInsightsDataResponse(proto.Message): - r"""Response for an export insights operation. - """ - - -class CreateIssueModelRequest(proto.Message): - r"""The request to create an issue model. - - Attributes: - parent (str): - Required. The parent resource of the issue - model. - issue_model (google.cloud.contact_center_insights_v1.types.IssueModel): - Required. The issue model to create. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - issue_model: resources.IssueModel = proto.Field( - proto.MESSAGE, - number=2, - message=resources.IssueModel, - ) - - -class CreateIssueModelMetadata(proto.Message): - r"""Metadata for creating an issue model. - - Attributes: - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation was - created. - end_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation finished - running. - request (google.cloud.contact_center_insights_v1.types.CreateIssueModelRequest): - The original request for creation. - """ - - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - request: 'CreateIssueModelRequest' = proto.Field( - proto.MESSAGE, - number=3, - message='CreateIssueModelRequest', - ) - - -class UpdateIssueModelRequest(proto.Message): - r"""The request to update an issue model. - - Attributes: - issue_model (google.cloud.contact_center_insights_v1.types.IssueModel): - Required. The new values for the issue model. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The list of fields to be updated. - """ - - issue_model: resources.IssueModel = proto.Field( - proto.MESSAGE, - number=1, - message=resources.IssueModel, - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class ListIssueModelsRequest(proto.Message): - r"""Request to list issue models. - - Attributes: - parent (str): - Required. The parent resource of the issue - model. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ListIssueModelsResponse(proto.Message): - r"""The response of listing issue models. - - Attributes: - issue_models (MutableSequence[google.cloud.contact_center_insights_v1.types.IssueModel]): - The issue models that match the request. - """ - - issue_models: MutableSequence[resources.IssueModel] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=resources.IssueModel, - ) - - -class GetIssueModelRequest(proto.Message): - r"""The request to get an issue model. - - Attributes: - name (str): - Required. The name of the issue model to get. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class DeleteIssueModelRequest(proto.Message): - r"""The request to delete an issue model. - - Attributes: - name (str): - Required. The name of the issue model to - delete. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class DeleteIssueModelMetadata(proto.Message): - r"""Metadata for deleting an issue model. - - Attributes: - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation was - created. - end_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation finished - running. - request (google.cloud.contact_center_insights_v1.types.DeleteIssueModelRequest): - The original request for deletion. - """ - - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - request: 'DeleteIssueModelRequest' = proto.Field( - proto.MESSAGE, - number=3, - message='DeleteIssueModelRequest', - ) - - -class DeployIssueModelRequest(proto.Message): - r"""The request to deploy an issue model. - - Attributes: - name (str): - Required. The issue model to deploy. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class DeployIssueModelResponse(proto.Message): - r"""The response to deploy an issue model. - """ - - -class DeployIssueModelMetadata(proto.Message): - r"""Metadata for deploying an issue model. - - Attributes: - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation was - created. - end_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation finished - running. - request (google.cloud.contact_center_insights_v1.types.DeployIssueModelRequest): - The original request for deployment. - """ - - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - request: 'DeployIssueModelRequest' = proto.Field( - proto.MESSAGE, - number=3, - message='DeployIssueModelRequest', - ) - - -class UndeployIssueModelRequest(proto.Message): - r"""The request to undeploy an issue model. - - Attributes: - name (str): - Required. The issue model to undeploy. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class UndeployIssueModelResponse(proto.Message): - r"""The response to undeploy an issue model. - """ - - -class UndeployIssueModelMetadata(proto.Message): - r"""Metadata for undeploying an issue model. - - Attributes: - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation was - created. - end_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the operation finished - running. - request (google.cloud.contact_center_insights_v1.types.UndeployIssueModelRequest): - The original request for undeployment. - """ - - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - request: 'UndeployIssueModelRequest' = proto.Field( - proto.MESSAGE, - number=3, - message='UndeployIssueModelRequest', - ) - - -class GetIssueRequest(proto.Message): - r"""The request to get an issue. - - Attributes: - name (str): - Required. The name of the issue to get. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ListIssuesRequest(proto.Message): - r"""Request to list issues. - - Attributes: - parent (str): - Required. The parent resource of the issue. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ListIssuesResponse(proto.Message): - r"""The response of listing issues. - - Attributes: - issues (MutableSequence[google.cloud.contact_center_insights_v1.types.Issue]): - The issues that match the request. - """ - - issues: MutableSequence[resources.Issue] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=resources.Issue, - ) - - -class UpdateIssueRequest(proto.Message): - r"""The request to update an issue. - - Attributes: - issue (google.cloud.contact_center_insights_v1.types.Issue): - Required. The new values for the issue. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The list of fields to be updated. - """ - - issue: resources.Issue = proto.Field( - proto.MESSAGE, - number=1, - message=resources.Issue, - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteIssueRequest(proto.Message): - r"""The request to delete an issue. - - Attributes: - name (str): - Required. The name of the issue to delete. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CalculateIssueModelStatsRequest(proto.Message): - r"""Request to get statistics of an issue model. - - Attributes: - issue_model (str): - Required. The resource name of the issue - model to query against. - """ - - issue_model: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CalculateIssueModelStatsResponse(proto.Message): - r"""Response of querying an issue model's statistics. - - Attributes: - current_stats (google.cloud.contact_center_insights_v1.types.IssueModelLabelStats): - The latest label statistics for the queried - issue model. Includes results on both training - data and data labeled after deployment. - """ - - current_stats: resources.IssueModelLabelStats = proto.Field( - proto.MESSAGE, - number=4, - message=resources.IssueModelLabelStats, - ) - - -class CreatePhraseMatcherRequest(proto.Message): - r"""Request to create a phrase matcher. - - Attributes: - parent (str): - Required. The parent resource of the phrase matcher. - Required. The location to create a phrase matcher for. - Format: ``projects//locations/`` or - ``projects//locations/`` - phrase_matcher (google.cloud.contact_center_insights_v1.types.PhraseMatcher): - Required. The phrase matcher resource to - create. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - phrase_matcher: resources.PhraseMatcher = proto.Field( - proto.MESSAGE, - number=2, - message=resources.PhraseMatcher, - ) - - -class ListPhraseMatchersRequest(proto.Message): - r"""Request to list phrase matchers. - - Attributes: - parent (str): - Required. The parent resource of the phrase - matcher. - page_size (int): - The maximum number of phrase matchers to return in the - response. If this value is zero, the service will select a - default size. A call might return fewer objects than - requested. A non-empty ``next_page_token`` in the response - indicates that more data is available. - page_token (str): - The value returned by the last - ``ListPhraseMatchersResponse``. This value indicates that - this is a continuation of a prior ``ListPhraseMatchers`` - call and that the system should return the next page of - data. - filter (str): - A filter to reduce results to a specific - subset. Useful for querying phrase matchers with - specific properties. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - page_size: int = proto.Field( - proto.INT32, - number=2, - ) - page_token: str = proto.Field( - proto.STRING, - number=3, - ) - filter: str = proto.Field( - proto.STRING, - number=4, - ) - - -class ListPhraseMatchersResponse(proto.Message): - r"""The response of listing phrase matchers. - - Attributes: - phrase_matchers (MutableSequence[google.cloud.contact_center_insights_v1.types.PhraseMatcher]): - The phrase matchers that match the request. - next_page_token (str): - A token, which can be sent as ``page_token`` to retrieve the - next page. If this field is omitted, there are no subsequent - pages. - """ - - @property - def raw_page(self): - return self - - phrase_matchers: MutableSequence[resources.PhraseMatcher] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=resources.PhraseMatcher, - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetPhraseMatcherRequest(proto.Message): - r"""The request to get a a phrase matcher. - - Attributes: - name (str): - Required. The name of the phrase matcher to - get. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class DeletePhraseMatcherRequest(proto.Message): - r"""The request to delete a phrase matcher. - - Attributes: - name (str): - Required. The name of the phrase matcher to - delete. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdatePhraseMatcherRequest(proto.Message): - r"""The request to update a phrase matcher. - - Attributes: - phrase_matcher (google.cloud.contact_center_insights_v1.types.PhraseMatcher): - Required. The new values for the phrase - matcher. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The list of fields to be updated. - """ - - phrase_matcher: resources.PhraseMatcher = proto.Field( - proto.MESSAGE, - number=1, - message=resources.PhraseMatcher, - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class GetSettingsRequest(proto.Message): - r"""The request to get project-level settings. - - Attributes: - name (str): - Required. The name of the settings resource - to get. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateSettingsRequest(proto.Message): - r"""The request to update project-level settings. - - Attributes: - settings (google.cloud.contact_center_insights_v1.types.Settings): - Required. The new settings values. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The list of fields to be updated. - """ - - settings: resources.Settings = proto.Field( - proto.MESSAGE, - number=1, - message=resources.Settings, - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class CreateViewRequest(proto.Message): - r"""The request to create a view. - - Attributes: - parent (str): - Required. The parent resource of the view. Required. The - location to create a view for. Format: - ``projects//locations/`` or - ``projects//locations/`` - view (google.cloud.contact_center_insights_v1.types.View): - Required. The view resource to create. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - view: resources.View = proto.Field( - proto.MESSAGE, - number=2, - message=resources.View, - ) - - -class GetViewRequest(proto.Message): - r"""The request to get a view. - - Attributes: - name (str): - Required. The name of the view to get. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ListViewsRequest(proto.Message): - r"""The request to list views. - - Attributes: - parent (str): - Required. The parent resource of the views. - page_size (int): - The maximum number of views to return in the response. If - this value is zero, the service will select a default size. - A call may return fewer objects than requested. A non-empty - ``next_page_token`` in the response indicates that more data - is available. - page_token (str): - The value returned by the last ``ListViewsResponse``; - indicates that this is a continuation of a prior - ``ListViews`` call and the system should return the next - page of data. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - page_size: int = proto.Field( - proto.INT32, - number=2, - ) - page_token: str = proto.Field( - proto.STRING, - number=3, - ) - - -class ListViewsResponse(proto.Message): - r"""The response of listing views. - - Attributes: - views (MutableSequence[google.cloud.contact_center_insights_v1.types.View]): - The views that match the request. - next_page_token (str): - A token, which can be sent as ``page_token`` to retrieve the - next page. If this field is omitted, there are no subsequent - pages. - """ - - @property - def raw_page(self): - return self - - views: MutableSequence[resources.View] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=resources.View, - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class UpdateViewRequest(proto.Message): - r"""The request to update a view. - - Attributes: - view (google.cloud.contact_center_insights_v1.types.View): - Required. The new view. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The list of fields to be updated. - """ - - view: resources.View = proto.Field( - proto.MESSAGE, - number=1, - message=resources.View, - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteViewRequest(proto.Message): - r"""The request to delete a view. - - Attributes: - name (str): - Required. The name of the view to delete. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/resources.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/resources.py deleted file mode 100644 index 4ac5858f06cd..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/google/cloud/contact_center_insights_v1/types/resources.py +++ /dev/null @@ -1,2539 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -from __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.contactcenterinsights.v1', - manifest={ - 'Conversation', - 'Analysis', - 'ConversationDataSource', - 'GcsSource', - 'DialogflowSource', - 'AnalysisResult', - 'IssueModelResult', - 'ConversationLevelSentiment', - 'IssueAssignment', - 'CallAnnotation', - 'AnnotationBoundary', - 'Entity', - 'Intent', - 'PhraseMatchData', - 'DialogflowIntent', - 'InterruptionData', - 'SilenceData', - 'HoldData', - 'EntityMentionData', - 'IntentMatchData', - 'SentimentData', - 'IssueMatchData', - 'IssueModel', - 'Issue', - 'IssueModelLabelStats', - 'PhraseMatcher', - 'PhraseMatchRuleGroup', - 'PhraseMatchRule', - 'PhraseMatchRuleConfig', - 'ExactMatchConfig', - 'Settings', - 'RedactionConfig', - 'SpeechConfig', - 'RuntimeAnnotation', - 'AnswerFeedback', - 'ArticleSuggestionData', - 'FaqAnswerData', - 'SmartReplyData', - 'SmartComposeSuggestionData', - 'DialogflowInteractionData', - 'ConversationSummarizationSuggestionData', - 'ConversationParticipant', - 'View', - 'AnnotatorSelector', - }, -) - - -class Conversation(proto.Message): - r"""The conversation resource. - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - call_metadata (google.cloud.contact_center_insights_v1.types.Conversation.CallMetadata): - Call-specific metadata. - - This field is a member of `oneof`_ ``metadata``. - expire_time (google.protobuf.timestamp_pb2.Timestamp): - The time at which this conversation should - expire. After this time, the conversation data - and any associated analyses will be deleted. - - This field is a member of `oneof`_ ``expiration``. - ttl (google.protobuf.duration_pb2.Duration): - Input only. The TTL for this resource. If - specified, then this TTL will be used to - calculate the expire time. - - This field is a member of `oneof`_ ``expiration``. - name (str): - Immutable. The resource name of the - conversation. Format: - - projects/{project}/locations/{location}/conversations/{conversation} - data_source (google.cloud.contact_center_insights_v1.types.ConversationDataSource): - The source of the audio and transcription for - the conversation. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which the - conversation was created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The most recent time at which - the conversation was updated. - start_time (google.protobuf.timestamp_pb2.Timestamp): - The time at which the conversation started. - language_code (str): - A user-specified language code for the - conversation. - agent_id (str): - An opaque, user-specified string representing - the human agent who handled the conversation. - labels (MutableMapping[str, str]): - A map for the user to specify any custom - fields. A maximum of 20 labels per conversation - is allowed, with a maximum of 256 characters per - entry. - transcript (google.cloud.contact_center_insights_v1.types.Conversation.Transcript): - Output only. The conversation transcript. - medium (google.cloud.contact_center_insights_v1.types.Conversation.Medium): - Immutable. The conversation medium, if unspecified will - default to PHONE_CALL. - duration (google.protobuf.duration_pb2.Duration): - Output only. The duration of the - conversation. - turn_count (int): - Output only. The number of turns in the - conversation. - latest_analysis (google.cloud.contact_center_insights_v1.types.Analysis): - Output only. The conversation's latest - analysis, if one exists. - latest_summary (google.cloud.contact_center_insights_v1.types.ConversationSummarizationSuggestionData): - Output only. Latest summary of the - conversation. - runtime_annotations (MutableSequence[google.cloud.contact_center_insights_v1.types.RuntimeAnnotation]): - Output only. The annotations that were - generated during the customer and agent - interaction. - dialogflow_intents (MutableMapping[str, google.cloud.contact_center_insights_v1.types.DialogflowIntent]): - Output only. All the matched Dialogflow - intents in the call. The key corresponds to a - Dialogflow intent, format: - - projects/{project}/agent/{agent}/intents/{intent} - obfuscated_user_id (str): - Obfuscated user ID which the customer sent to - us. - """ - class Medium(proto.Enum): - r"""Possible media for the conversation. - - Values: - MEDIUM_UNSPECIFIED (0): - Default value, if unspecified will default to PHONE_CALL. - PHONE_CALL (1): - The format for conversations that took place - over the phone. - CHAT (2): - The format for conversations that took place - over chat. - """ - MEDIUM_UNSPECIFIED = 0 - PHONE_CALL = 1 - CHAT = 2 - - class CallMetadata(proto.Message): - r"""Call-specific metadata. - - Attributes: - customer_channel (int): - The audio channel that contains the customer. - agent_channel (int): - The audio channel that contains the agent. - """ - - customer_channel: int = proto.Field( - proto.INT32, - number=1, - ) - agent_channel: int = proto.Field( - proto.INT32, - number=2, - ) - - class Transcript(proto.Message): - r"""A message representing the transcript of a conversation. - - Attributes: - transcript_segments (MutableSequence[google.cloud.contact_center_insights_v1.types.Conversation.Transcript.TranscriptSegment]): - A list of sequential transcript segments that - comprise the conversation. - """ - - class TranscriptSegment(proto.Message): - r"""A segment of a full transcript. - - Attributes: - message_time (google.protobuf.timestamp_pb2.Timestamp): - The time that the message occurred, if - provided. - text (str): - The text of this segment. - confidence (float): - A confidence estimate between 0.0 and 1.0 of - the fidelity of this segment. A default value of - 0.0 indicates that the value is unset. - words (MutableSequence[google.cloud.contact_center_insights_v1.types.Conversation.Transcript.TranscriptSegment.WordInfo]): - A list of the word-specific information for - each word in the segment. - language_code (str): - The language code of this segment as a - `BCP-47 `__ - language tag. Example: "en-US". - channel_tag (int): - For conversations derived from multi-channel - audio, this is the channel number corresponding - to the audio from that channel. For - audioChannelCount = N, its output values can - range from '1' to 'N'. A channel tag of 0 - indicates that the audio is mono. - segment_participant (google.cloud.contact_center_insights_v1.types.ConversationParticipant): - The participant of this segment. - dialogflow_segment_metadata (google.cloud.contact_center_insights_v1.types.Conversation.Transcript.TranscriptSegment.DialogflowSegmentMetadata): - CCAI metadata relating to the current - transcript segment. - sentiment (google.cloud.contact_center_insights_v1.types.SentimentData): - The sentiment for this transcript segment. - """ - - class WordInfo(proto.Message): - r"""Word-level info for words in a transcript. - - Attributes: - start_offset (google.protobuf.duration_pb2.Duration): - Time offset of the start of this word - relative to the beginning of the total - conversation. - end_offset (google.protobuf.duration_pb2.Duration): - Time offset of the end of this word relative - to the beginning of the total conversation. - word (str): - The word itself. Includes punctuation marks - that surround the word. - confidence (float): - A confidence estimate between 0.0 and 1.0 of - the fidelity of this word. A default value of - 0.0 indicates that the value is unset. - """ - - start_offset: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=1, - message=duration_pb2.Duration, - ) - end_offset: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=2, - message=duration_pb2.Duration, - ) - word: str = proto.Field( - proto.STRING, - number=3, - ) - confidence: float = proto.Field( - proto.FLOAT, - number=4, - ) - - class DialogflowSegmentMetadata(proto.Message): - r"""Metadata from Dialogflow relating to the current transcript - segment. - - Attributes: - smart_reply_allowlist_covered (bool): - Whether the transcript segment was covered - under the configured smart reply allowlist in - Agent Assist. - """ - - smart_reply_allowlist_covered: bool = proto.Field( - proto.BOOL, - number=1, - ) - - message_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - text: str = proto.Field( - proto.STRING, - number=1, - ) - confidence: float = proto.Field( - proto.FLOAT, - number=2, - ) - words: MutableSequence['Conversation.Transcript.TranscriptSegment.WordInfo'] = proto.RepeatedField( - proto.MESSAGE, - number=3, - message='Conversation.Transcript.TranscriptSegment.WordInfo', - ) - language_code: str = proto.Field( - proto.STRING, - number=4, - ) - channel_tag: int = proto.Field( - proto.INT32, - number=5, - ) - segment_participant: 'ConversationParticipant' = proto.Field( - proto.MESSAGE, - number=9, - message='ConversationParticipant', - ) - dialogflow_segment_metadata: 'Conversation.Transcript.TranscriptSegment.DialogflowSegmentMetadata' = proto.Field( - proto.MESSAGE, - number=10, - message='Conversation.Transcript.TranscriptSegment.DialogflowSegmentMetadata', - ) - sentiment: 'SentimentData' = proto.Field( - proto.MESSAGE, - number=11, - message='SentimentData', - ) - - transcript_segments: MutableSequence['Conversation.Transcript.TranscriptSegment'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Conversation.Transcript.TranscriptSegment', - ) - - call_metadata: CallMetadata = proto.Field( - proto.MESSAGE, - number=7, - oneof='metadata', - message=CallMetadata, - ) - expire_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=15, - oneof='expiration', - message=timestamp_pb2.Timestamp, - ) - ttl: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=16, - oneof='expiration', - message=duration_pb2.Duration, - ) - name: str = proto.Field( - proto.STRING, - number=1, - ) - data_source: 'ConversationDataSource' = proto.Field( - proto.MESSAGE, - number=2, - message='ConversationDataSource', - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.Timestamp, - ) - start_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=17, - message=timestamp_pb2.Timestamp, - ) - language_code: str = proto.Field( - proto.STRING, - number=14, - ) - agent_id: str = proto.Field( - proto.STRING, - number=5, - ) - labels: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=6, - ) - transcript: Transcript = proto.Field( - proto.MESSAGE, - number=8, - message=Transcript, - ) - medium: Medium = proto.Field( - proto.ENUM, - number=9, - enum=Medium, - ) - duration: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=10, - message=duration_pb2.Duration, - ) - turn_count: int = proto.Field( - proto.INT32, - number=11, - ) - latest_analysis: 'Analysis' = proto.Field( - proto.MESSAGE, - number=12, - message='Analysis', - ) - latest_summary: 'ConversationSummarizationSuggestionData' = proto.Field( - proto.MESSAGE, - number=20, - message='ConversationSummarizationSuggestionData', - ) - runtime_annotations: MutableSequence['RuntimeAnnotation'] = proto.RepeatedField( - proto.MESSAGE, - number=13, - message='RuntimeAnnotation', - ) - dialogflow_intents: MutableMapping[str, 'DialogflowIntent'] = proto.MapField( - proto.STRING, - proto.MESSAGE, - number=18, - message='DialogflowIntent', - ) - obfuscated_user_id: str = proto.Field( - proto.STRING, - number=21, - ) - - -class Analysis(proto.Message): - r"""The analysis resource. - - Attributes: - name (str): - Immutable. The resource name of the analysis. - Format: - - projects/{project}/locations/{location}/conversations/{conversation}/analyses/{analysis} - request_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which the analysis - was requested. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which the analysis - was created, which occurs when the long-running - operation completes. - analysis_result (google.cloud.contact_center_insights_v1.types.AnalysisResult): - Output only. The result of the analysis, - which is populated when the analysis finishes. - annotator_selector (google.cloud.contact_center_insights_v1.types.AnnotatorSelector): - To select the annotators to run and the - phrase matchers to use (if any). If not - specified, all annotators will be run. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - request_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - analysis_result: 'AnalysisResult' = proto.Field( - proto.MESSAGE, - number=7, - message='AnalysisResult', - ) - annotator_selector: 'AnnotatorSelector' = proto.Field( - proto.MESSAGE, - number=8, - message='AnnotatorSelector', - ) - - -class ConversationDataSource(proto.Message): - r"""The conversation source, which is a combination of transcript - and audio. - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - gcs_source (google.cloud.contact_center_insights_v1.types.GcsSource): - A Cloud Storage location specification for - the audio and transcript. - - This field is a member of `oneof`_ ``source``. - dialogflow_source (google.cloud.contact_center_insights_v1.types.DialogflowSource): - The source when the conversation comes from - Dialogflow. - - This field is a member of `oneof`_ ``source``. - """ - - gcs_source: 'GcsSource' = proto.Field( - proto.MESSAGE, - number=1, - oneof='source', - message='GcsSource', - ) - dialogflow_source: 'DialogflowSource' = proto.Field( - proto.MESSAGE, - number=3, - oneof='source', - message='DialogflowSource', - ) - - -class GcsSource(proto.Message): - r"""A Cloud Storage source of conversation data. - - Attributes: - audio_uri (str): - Cloud Storage URI that points to a file that - contains the conversation audio. - transcript_uri (str): - Immutable. Cloud Storage URI that points to a - file that contains the conversation transcript. - """ - - audio_uri: str = proto.Field( - proto.STRING, - number=1, - ) - transcript_uri: str = proto.Field( - proto.STRING, - number=2, - ) - - -class DialogflowSource(proto.Message): - r"""A Dialogflow source of conversation data. - - Attributes: - dialogflow_conversation (str): - Output only. The name of the Dialogflow - conversation that this conversation resource is - derived from. Format: - - projects/{project}/locations/{location}/conversations/{conversation} - audio_uri (str): - Cloud Storage URI that points to a file that - contains the conversation audio. - """ - - dialogflow_conversation: str = proto.Field( - proto.STRING, - number=1, - ) - audio_uri: str = proto.Field( - proto.STRING, - number=3, - ) - - -class AnalysisResult(proto.Message): - r"""The result of an analysis. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - call_analysis_metadata (google.cloud.contact_center_insights_v1.types.AnalysisResult.CallAnalysisMetadata): - Call-specific metadata created by the - analysis. - - This field is a member of `oneof`_ ``metadata``. - end_time (google.protobuf.timestamp_pb2.Timestamp): - The time at which the analysis ended. - """ - - class CallAnalysisMetadata(proto.Message): - r"""Call-specific metadata created during analysis. - - Attributes: - annotations (MutableSequence[google.cloud.contact_center_insights_v1.types.CallAnnotation]): - A list of call annotations that apply to this - call. - entities (MutableMapping[str, google.cloud.contact_center_insights_v1.types.Entity]): - All the entities in the call. - sentiments (MutableSequence[google.cloud.contact_center_insights_v1.types.ConversationLevelSentiment]): - Overall conversation-level sentiment for each - channel of the call. - intents (MutableMapping[str, google.cloud.contact_center_insights_v1.types.Intent]): - All the matched intents in the call. - phrase_matchers (MutableMapping[str, google.cloud.contact_center_insights_v1.types.PhraseMatchData]): - All the matched phrase matchers in the call. - issue_model_result (google.cloud.contact_center_insights_v1.types.IssueModelResult): - Overall conversation-level issue modeling - result. - """ - - annotations: MutableSequence['CallAnnotation'] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='CallAnnotation', - ) - entities: MutableMapping[str, 'Entity'] = proto.MapField( - proto.STRING, - proto.MESSAGE, - number=3, - message='Entity', - ) - sentiments: MutableSequence['ConversationLevelSentiment'] = proto.RepeatedField( - proto.MESSAGE, - number=4, - message='ConversationLevelSentiment', - ) - intents: MutableMapping[str, 'Intent'] = proto.MapField( - proto.STRING, - proto.MESSAGE, - number=6, - message='Intent', - ) - phrase_matchers: MutableMapping[str, 'PhraseMatchData'] = proto.MapField( - proto.STRING, - proto.MESSAGE, - number=7, - message='PhraseMatchData', - ) - issue_model_result: 'IssueModelResult' = proto.Field( - proto.MESSAGE, - number=8, - message='IssueModelResult', - ) - - call_analysis_metadata: CallAnalysisMetadata = proto.Field( - proto.MESSAGE, - number=2, - oneof='metadata', - message=CallAnalysisMetadata, - ) - end_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - - -class IssueModelResult(proto.Message): - r"""Issue Modeling result on a conversation. - - Attributes: - issue_model (str): - Issue model that generates the result. Format: - projects/{project}/locations/{location}/issueModels/{issue_model} - issues (MutableSequence[google.cloud.contact_center_insights_v1.types.IssueAssignment]): - All the matched issues. - """ - - issue_model: str = proto.Field( - proto.STRING, - number=1, - ) - issues: MutableSequence['IssueAssignment'] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='IssueAssignment', - ) - - -class ConversationLevelSentiment(proto.Message): - r"""One channel of conversation-level sentiment data. - - Attributes: - channel_tag (int): - The channel of the audio that the data - applies to. - sentiment_data (google.cloud.contact_center_insights_v1.types.SentimentData): - Data specifying sentiment. - """ - - channel_tag: int = proto.Field( - proto.INT32, - number=1, - ) - sentiment_data: 'SentimentData' = proto.Field( - proto.MESSAGE, - number=2, - message='SentimentData', - ) - - -class IssueAssignment(proto.Message): - r"""Information about the issue. - - Attributes: - issue (str): - Resource name of the assigned issue. - score (float): - Score indicating the likelihood of the issue assignment. - currently bounded on [0,1]. - display_name (str): - Immutable. Display name of the assigned - issue. This field is set at time of analyis and - immutable since then. - """ - - issue: str = proto.Field( - proto.STRING, - number=1, - ) - score: float = proto.Field( - proto.DOUBLE, - number=2, - ) - display_name: str = proto.Field( - proto.STRING, - number=3, - ) - - -class CallAnnotation(proto.Message): - r"""A piece of metadata that applies to a window of a call. - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - interruption_data (google.cloud.contact_center_insights_v1.types.InterruptionData): - Data specifying an interruption. - - This field is a member of `oneof`_ ``data``. - sentiment_data (google.cloud.contact_center_insights_v1.types.SentimentData): - Data specifying sentiment. - - This field is a member of `oneof`_ ``data``. - silence_data (google.cloud.contact_center_insights_v1.types.SilenceData): - Data specifying silence. - - This field is a member of `oneof`_ ``data``. - hold_data (google.cloud.contact_center_insights_v1.types.HoldData): - Data specifying a hold. - - This field is a member of `oneof`_ ``data``. - entity_mention_data (google.cloud.contact_center_insights_v1.types.EntityMentionData): - Data specifying an entity mention. - - This field is a member of `oneof`_ ``data``. - intent_match_data (google.cloud.contact_center_insights_v1.types.IntentMatchData): - Data specifying an intent match. - - This field is a member of `oneof`_ ``data``. - phrase_match_data (google.cloud.contact_center_insights_v1.types.PhraseMatchData): - Data specifying a phrase match. - - This field is a member of `oneof`_ ``data``. - issue_match_data (google.cloud.contact_center_insights_v1.types.IssueMatchData): - Data specifying an issue match. - - This field is a member of `oneof`_ ``data``. - channel_tag (int): - The channel of the audio where the annotation - occurs. For single-channel audio, this field is - not populated. - annotation_start_boundary (google.cloud.contact_center_insights_v1.types.AnnotationBoundary): - The boundary in the conversation where the - annotation starts, inclusive. - annotation_end_boundary (google.cloud.contact_center_insights_v1.types.AnnotationBoundary): - The boundary in the conversation where the - annotation ends, inclusive. - """ - - interruption_data: 'InterruptionData' = proto.Field( - proto.MESSAGE, - number=10, - oneof='data', - message='InterruptionData', - ) - sentiment_data: 'SentimentData' = proto.Field( - proto.MESSAGE, - number=11, - oneof='data', - message='SentimentData', - ) - silence_data: 'SilenceData' = proto.Field( - proto.MESSAGE, - number=12, - oneof='data', - message='SilenceData', - ) - hold_data: 'HoldData' = proto.Field( - proto.MESSAGE, - number=13, - oneof='data', - message='HoldData', - ) - entity_mention_data: 'EntityMentionData' = proto.Field( - proto.MESSAGE, - number=15, - oneof='data', - message='EntityMentionData', - ) - intent_match_data: 'IntentMatchData' = proto.Field( - proto.MESSAGE, - number=16, - oneof='data', - message='IntentMatchData', - ) - phrase_match_data: 'PhraseMatchData' = proto.Field( - proto.MESSAGE, - number=17, - oneof='data', - message='PhraseMatchData', - ) - issue_match_data: 'IssueMatchData' = proto.Field( - proto.MESSAGE, - number=18, - oneof='data', - message='IssueMatchData', - ) - channel_tag: int = proto.Field( - proto.INT32, - number=1, - ) - annotation_start_boundary: 'AnnotationBoundary' = proto.Field( - proto.MESSAGE, - number=4, - message='AnnotationBoundary', - ) - annotation_end_boundary: 'AnnotationBoundary' = proto.Field( - proto.MESSAGE, - number=5, - message='AnnotationBoundary', - ) - - -class AnnotationBoundary(proto.Message): - r"""A point in a conversation that marks the start or the end of - an annotation. - - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - word_index (int): - The word index of this boundary with respect - to the first word in the transcript piece. This - index starts at zero. - - This field is a member of `oneof`_ ``detailed_boundary``. - transcript_index (int): - The index in the sequence of transcribed - pieces of the conversation where the boundary is - located. This index starts at zero. - """ - - word_index: int = proto.Field( - proto.INT32, - number=3, - oneof='detailed_boundary', - ) - transcript_index: int = proto.Field( - proto.INT32, - number=1, - ) - - -class Entity(proto.Message): - r"""The data for an entity annotation. - Represents a phrase in the conversation that is a known entity, - such as a person, an organization, or location. - - Attributes: - display_name (str): - The representative name for the entity. - type_ (google.cloud.contact_center_insights_v1.types.Entity.Type): - The entity type. - metadata (MutableMapping[str, str]): - Metadata associated with the entity. - - For most entity types, the metadata is a Wikipedia URL - (``wikipedia_url``) and Knowledge Graph MID (``mid``), if - they are available. For the metadata associated with other - entity types, see the Type table below. - salience (float): - The salience score associated with the entity in the [0, - 1.0] range. - - The salience score for an entity provides information about - the importance or centrality of that entity to the entire - document text. Scores closer to 0 are less salient, while - scores closer to 1.0 are highly salient. - sentiment (google.cloud.contact_center_insights_v1.types.SentimentData): - The aggregate sentiment expressed for this - entity in the conversation. - """ - class Type(proto.Enum): - r"""The type of the entity. For most entity types, the associated - metadata is a Wikipedia URL (``wikipedia_url``) and Knowledge Graph - MID (``mid``). The table below lists the associated fields for - entities that have different metadata. - - Values: - TYPE_UNSPECIFIED (0): - Unspecified. - PERSON (1): - Person. - LOCATION (2): - Location. - ORGANIZATION (3): - Organization. - EVENT (4): - Event. - WORK_OF_ART (5): - Artwork. - CONSUMER_GOOD (6): - Consumer product. - OTHER (7): - Other types of entities. - PHONE_NUMBER (9): - Phone number. - - The metadata lists the phone number (formatted according to - local convention), plus whichever additional elements appear - in the text: - - - ``number`` - The actual number, broken down into sections - according to local convention. - - ``national_prefix`` - Country code, if detected. - - ``area_code`` - Region or area code, if detected. - - ``extension`` - Phone extension (to be dialed after - connection), if detected. - ADDRESS (10): - Address. - - The metadata identifies the street number and locality plus - whichever additional elements appear in the text: - - - ``street_number`` - Street number. - - ``locality`` - City or town. - - ``street_name`` - Street/route name, if detected. - - ``postal_code`` - Postal code, if detected. - - ``country`` - Country, if detected. - - ``broad_region`` - Administrative area, such as the - state, if detected. - - ``narrow_region`` - Smaller administrative area, such as - county, if detected. - - ``sublocality`` - Used in Asian addresses to demark a - district within a city, if detected. - DATE (11): - Date. - - The metadata identifies the components of the date: - - - ``year`` - Four digit year, if detected. - - ``month`` - Two digit month number, if detected. - - ``day`` - Two digit day number, if detected. - NUMBER (12): - Number. - - The metadata is the number itself. - PRICE (13): - Price. - - The metadata identifies the ``value`` and ``currency``. - """ - TYPE_UNSPECIFIED = 0 - PERSON = 1 - LOCATION = 2 - ORGANIZATION = 3 - EVENT = 4 - WORK_OF_ART = 5 - CONSUMER_GOOD = 6 - OTHER = 7 - PHONE_NUMBER = 9 - ADDRESS = 10 - DATE = 11 - NUMBER = 12 - PRICE = 13 - - display_name: str = proto.Field( - proto.STRING, - number=1, - ) - type_: Type = proto.Field( - proto.ENUM, - number=2, - enum=Type, - ) - metadata: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=3, - ) - salience: float = proto.Field( - proto.FLOAT, - number=4, - ) - sentiment: 'SentimentData' = proto.Field( - proto.MESSAGE, - number=5, - message='SentimentData', - ) - - -class Intent(proto.Message): - r"""The data for an intent. Represents a detected intent in the - conversation, for example MAKES_PROMISE. - - Attributes: - id (str): - The unique identifier of the intent. - display_name (str): - The human-readable name of the intent. - """ - - id: str = proto.Field( - proto.STRING, - number=1, - ) - display_name: str = proto.Field( - proto.STRING, - number=2, - ) - - -class PhraseMatchData(proto.Message): - r"""The data for a matched phrase matcher. - Represents information identifying a phrase matcher for a given - match. - - Attributes: - phrase_matcher (str): - The unique identifier (the resource name) of - the phrase matcher. - display_name (str): - The human-readable name of the phrase - matcher. - """ - - phrase_matcher: str = proto.Field( - proto.STRING, - number=1, - ) - display_name: str = proto.Field( - proto.STRING, - number=2, - ) - - -class DialogflowIntent(proto.Message): - r"""The data for a Dialogflow intent. Represents a detected intent in - the conversation, e.g. MAKES_PROMISE. - - Attributes: - display_name (str): - The human-readable name of the intent. - """ - - display_name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class InterruptionData(proto.Message): - r"""The data for an interruption annotation. - """ - - -class SilenceData(proto.Message): - r"""The data for a silence annotation. - """ - - -class HoldData(proto.Message): - r"""The data for a hold annotation. - """ - - -class EntityMentionData(proto.Message): - r"""The data for an entity mention annotation. This represents a mention - of an ``Entity`` in the conversation. - - Attributes: - entity_unique_id (str): - The key of this entity in conversation entities. Can be used - to retrieve the exact ``Entity`` this mention is attached - to. - type_ (google.cloud.contact_center_insights_v1.types.EntityMentionData.MentionType): - The type of the entity mention. - sentiment (google.cloud.contact_center_insights_v1.types.SentimentData): - Sentiment expressed for this mention of the - entity. - """ - class MentionType(proto.Enum): - r"""The supported types of mentions. - - Values: - MENTION_TYPE_UNSPECIFIED (0): - Unspecified. - PROPER (1): - Proper noun. - COMMON (2): - Common noun (or noun compound). - """ - MENTION_TYPE_UNSPECIFIED = 0 - PROPER = 1 - COMMON = 2 - - entity_unique_id: str = proto.Field( - proto.STRING, - number=1, - ) - type_: MentionType = proto.Field( - proto.ENUM, - number=2, - enum=MentionType, - ) - sentiment: 'SentimentData' = proto.Field( - proto.MESSAGE, - number=3, - message='SentimentData', - ) - - -class IntentMatchData(proto.Message): - r"""The data for an intent match. - Represents an intent match for a text segment in the - conversation. A text segment can be part of a sentence, a - complete sentence, or an utterance with multiple sentences. - - Attributes: - intent_unique_id (str): - The id of the matched intent. - Can be used to retrieve the corresponding intent - information. - """ - - intent_unique_id: str = proto.Field( - proto.STRING, - number=1, - ) - - -class SentimentData(proto.Message): - r"""The data for a sentiment annotation. - - Attributes: - magnitude (float): - A non-negative number from 0 to infinity - which represents the abolute magnitude of - sentiment regardless of score. - score (float): - The sentiment score between -1.0 (negative) - and 1.0 (positive). - """ - - magnitude: float = proto.Field( - proto.FLOAT, - number=1, - ) - score: float = proto.Field( - proto.FLOAT, - number=2, - ) - - -class IssueMatchData(proto.Message): - r"""The data for an issue match annotation. - - Attributes: - issue_assignment (google.cloud.contact_center_insights_v1.types.IssueAssignment): - Information about the issue's assignment. - """ - - issue_assignment: 'IssueAssignment' = proto.Field( - proto.MESSAGE, - number=1, - message='IssueAssignment', - ) - - -class IssueModel(proto.Message): - r"""The issue model resource. - - Attributes: - name (str): - Immutable. The resource name of the issue model. Format: - projects/{project}/locations/{location}/issueModels/{issue_model} - display_name (str): - The representative name for the issue model. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this issue - model was created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The most recent time at which - the issue model was updated. - issue_count (int): - Output only. Number of issues in this issue - model. - state (google.cloud.contact_center_insights_v1.types.IssueModel.State): - Output only. State of the model. - input_data_config (google.cloud.contact_center_insights_v1.types.IssueModel.InputDataConfig): - Configs for the input data that used to - create the issue model. - training_stats (google.cloud.contact_center_insights_v1.types.IssueModelLabelStats): - Output only. Immutable. The issue model's - label statistics on its training data. - model_type (google.cloud.contact_center_insights_v1.types.IssueModel.ModelType): - Type of the model. - language_code (str): - Language of the model. - """ - class State(proto.Enum): - r"""State of the model. - - Values: - STATE_UNSPECIFIED (0): - Unspecified. - UNDEPLOYED (1): - Model is not deployed but is ready to deploy. - DEPLOYING (2): - Model is being deployed. - DEPLOYED (3): - Model is deployed and is ready to be used. A - model can only be used in analysis if it's in - this state. - UNDEPLOYING (4): - Model is being undeployed. - DELETING (5): - Model is being deleted. - """ - STATE_UNSPECIFIED = 0 - UNDEPLOYED = 1 - DEPLOYING = 2 - DEPLOYED = 3 - UNDEPLOYING = 4 - DELETING = 5 - - class ModelType(proto.Enum): - r"""Type of the model. - - Values: - MODEL_TYPE_UNSPECIFIED (0): - Unspecified model type. - TYPE_V1 (1): - Type V1. - TYPE_V2 (2): - Type V2. - """ - MODEL_TYPE_UNSPECIFIED = 0 - TYPE_V1 = 1 - TYPE_V2 = 2 - - class InputDataConfig(proto.Message): - r"""Configs for the input data used to create the issue model. - - Attributes: - medium (google.cloud.contact_center_insights_v1.types.Conversation.Medium): - Medium of conversations used in training data. This field is - being deprecated. To specify the medium to be used in - training a new issue model, set the ``medium`` field on - ``filter``. - training_conversations_count (int): - Output only. Number of conversations used in - training. Output only. - filter (str): - A filter to reduce the conversations used for - training the model to a specific subset. - """ - - medium: 'Conversation.Medium' = proto.Field( - proto.ENUM, - number=1, - enum='Conversation.Medium', - ) - training_conversations_count: int = proto.Field( - proto.INT64, - number=2, - ) - filter: str = proto.Field( - proto.STRING, - number=3, - ) - - name: str = proto.Field( - proto.STRING, - number=1, - ) - display_name: str = proto.Field( - proto.STRING, - number=2, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.Timestamp, - ) - issue_count: int = proto.Field( - proto.INT64, - number=8, - ) - state: State = proto.Field( - proto.ENUM, - number=5, - enum=State, - ) - input_data_config: InputDataConfig = proto.Field( - proto.MESSAGE, - number=6, - message=InputDataConfig, - ) - training_stats: 'IssueModelLabelStats' = proto.Field( - proto.MESSAGE, - number=7, - message='IssueModelLabelStats', - ) - model_type: ModelType = proto.Field( - proto.ENUM, - number=9, - enum=ModelType, - ) - language_code: str = proto.Field( - proto.STRING, - number=10, - ) - - -class Issue(proto.Message): - r"""The issue resource. - - Attributes: - name (str): - Immutable. The resource name of the issue. Format: - projects/{project}/locations/{location}/issueModels/{issue_model}/issues/{issue} - display_name (str): - The representative name for the issue. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this issue was - created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The most recent time that this - issue was updated. - sample_utterances (MutableSequence[str]): - Output only. Resource names of the sample - representative utterances that match to this - issue. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - display_name: str = proto.Field( - proto.STRING, - number=2, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.Timestamp, - ) - sample_utterances: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=6, - ) - - -class IssueModelLabelStats(proto.Message): - r"""Aggregated statistics about an issue model. - - Attributes: - analyzed_conversations_count (int): - Number of conversations the issue model has - analyzed at this point in time. - unclassified_conversations_count (int): - Number of analyzed conversations for which no - issue was applicable at this point in time. - issue_stats (MutableMapping[str, google.cloud.contact_center_insights_v1.types.IssueModelLabelStats.IssueStats]): - Statistics on each issue. Key is the issue's - resource name. - """ - - class IssueStats(proto.Message): - r"""Aggregated statistics about an issue. - - Attributes: - issue (str): - Issue resource. Format: - projects/{project}/locations/{location}/issueModels/{issue_model}/issues/{issue} - labeled_conversations_count (int): - Number of conversations attached to the issue - at this point in time. - display_name (str): - Display name of the issue. - """ - - issue: str = proto.Field( - proto.STRING, - number=1, - ) - labeled_conversations_count: int = proto.Field( - proto.INT64, - number=2, - ) - display_name: str = proto.Field( - proto.STRING, - number=3, - ) - - analyzed_conversations_count: int = proto.Field( - proto.INT64, - number=1, - ) - unclassified_conversations_count: int = proto.Field( - proto.INT64, - number=2, - ) - issue_stats: MutableMapping[str, IssueStats] = proto.MapField( - proto.STRING, - proto.MESSAGE, - number=3, - message=IssueStats, - ) - - -class PhraseMatcher(proto.Message): - r"""The phrase matcher resource. - - Attributes: - name (str): - The resource name of the phrase matcher. Format: - projects/{project}/locations/{location}/phraseMatchers/{phrase_matcher} - revision_id (str): - Output only. Immutable. The revision ID of - the phrase matcher. A new revision is committed - whenever the matcher is changed, except when it - is activated or deactivated. A server generated - random ID will be used. Example: - locations/global/phraseMatchers/my-first-matcher@1234567 - version_tag (str): - The customized version tag to use for the phrase matcher. If - not specified, it will default to ``revision_id``. - revision_create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The timestamp of when the - revision was created. It is also the create time - when a new matcher is added. - display_name (str): - The human-readable name of the phrase - matcher. - type_ (google.cloud.contact_center_insights_v1.types.PhraseMatcher.PhraseMatcherType): - Required. The type of this phrase matcher. - active (bool): - Applies the phrase matcher only when it is - active. - phrase_match_rule_groups (MutableSequence[google.cloud.contact_center_insights_v1.types.PhraseMatchRuleGroup]): - A list of phase match rule groups that are - included in this matcher. - activation_update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The most recent time at which - the activation status was updated. - role_match (google.cloud.contact_center_insights_v1.types.ConversationParticipant.Role): - The role whose utterances the phrase matcher should be - matched against. If the role is ROLE_UNSPECIFIED it will be - matched against any utterances in the transcript. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The most recent time at which - the phrase matcher was updated. - """ - class PhraseMatcherType(proto.Enum): - r"""Specifies how to combine each phrase match rule group to - determine whether there is a match. - - Values: - PHRASE_MATCHER_TYPE_UNSPECIFIED (0): - Unspecified. - ALL_OF (1): - Must meet all phrase match rule groups or - there is no match. - ANY_OF (2): - If any of the phrase match rule groups are - met, there is a match. - """ - PHRASE_MATCHER_TYPE_UNSPECIFIED = 0 - ALL_OF = 1 - ANY_OF = 2 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - revision_id: str = proto.Field( - proto.STRING, - number=2, - ) - version_tag: str = proto.Field( - proto.STRING, - number=3, - ) - revision_create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.Timestamp, - ) - display_name: str = proto.Field( - proto.STRING, - number=5, - ) - type_: PhraseMatcherType = proto.Field( - proto.ENUM, - number=6, - enum=PhraseMatcherType, - ) - active: bool = proto.Field( - proto.BOOL, - number=7, - ) - phrase_match_rule_groups: MutableSequence['PhraseMatchRuleGroup'] = proto.RepeatedField( - proto.MESSAGE, - number=8, - message='PhraseMatchRuleGroup', - ) - activation_update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=9, - message=timestamp_pb2.Timestamp, - ) - role_match: 'ConversationParticipant.Role' = proto.Field( - proto.ENUM, - number=10, - enum='ConversationParticipant.Role', - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=11, - message=timestamp_pb2.Timestamp, - ) - - -class PhraseMatchRuleGroup(proto.Message): - r"""A message representing a rule in the phrase matcher. - - Attributes: - type_ (google.cloud.contact_center_insights_v1.types.PhraseMatchRuleGroup.PhraseMatchRuleGroupType): - Required. The type of this phrase match rule - group. - phrase_match_rules (MutableSequence[google.cloud.contact_center_insights_v1.types.PhraseMatchRule]): - A list of phrase match rules that are - included in this group. - """ - class PhraseMatchRuleGroupType(proto.Enum): - r"""Specifies how to combine each phrase match rule for whether - there is a match. - - Values: - PHRASE_MATCH_RULE_GROUP_TYPE_UNSPECIFIED (0): - Unspecified. - ALL_OF (1): - Must meet all phrase match rules or there is - no match. - ANY_OF (2): - If any of the phrase match rules are met, - there is a match. - """ - PHRASE_MATCH_RULE_GROUP_TYPE_UNSPECIFIED = 0 - ALL_OF = 1 - ANY_OF = 2 - - type_: PhraseMatchRuleGroupType = proto.Field( - proto.ENUM, - number=1, - enum=PhraseMatchRuleGroupType, - ) - phrase_match_rules: MutableSequence['PhraseMatchRule'] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='PhraseMatchRule', - ) - - -class PhraseMatchRule(proto.Message): - r"""The data for a phrase match rule. - - Attributes: - query (str): - Required. The phrase to be matched. - negated (bool): - Specifies whether the phrase must be missing - from the transcript segment or present in the - transcript segment. - config (google.cloud.contact_center_insights_v1.types.PhraseMatchRuleConfig): - Provides additional information about the - rule that specifies how to apply the rule. - """ - - query: str = proto.Field( - proto.STRING, - number=1, - ) - negated: bool = proto.Field( - proto.BOOL, - number=2, - ) - config: 'PhraseMatchRuleConfig' = proto.Field( - proto.MESSAGE, - number=3, - message='PhraseMatchRuleConfig', - ) - - -class PhraseMatchRuleConfig(proto.Message): - r"""Configuration information of a phrase match rule. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - exact_match_config (google.cloud.contact_center_insights_v1.types.ExactMatchConfig): - The configuration for the exact match rule. - - This field is a member of `oneof`_ ``config``. - """ - - exact_match_config: 'ExactMatchConfig' = proto.Field( - proto.MESSAGE, - number=1, - oneof='config', - message='ExactMatchConfig', - ) - - -class ExactMatchConfig(proto.Message): - r"""Exact match configuration. - - Attributes: - case_sensitive (bool): - Whether to consider case sensitivity when - performing an exact match. - """ - - case_sensitive: bool = proto.Field( - proto.BOOL, - number=1, - ) - - -class Settings(proto.Message): - r"""The settings resource. - - Attributes: - name (str): - Immutable. The resource name of the settings - resource. Format: - - projects/{project}/locations/{location}/settings - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which the settings - was created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which the settings - were last updated. - language_code (str): - A language code to be applied to each - transcript segment unless the segment already - specifies a language code. Language code - defaults to "en-US" if it is neither specified - on the segment nor here. - conversation_ttl (google.protobuf.duration_pb2.Duration): - The default TTL for newly-created - conversations. If a conversation has a specified - expiration, that value will be used instead. - Changing this value will not change the - expiration of existing conversations. - Conversations with no expire time persist until - they are deleted. - pubsub_notification_settings (MutableMapping[str, str]): - A map that maps a notification trigger to a Pub/Sub topic. - Each time a specified trigger occurs, Insights will notify - the corresponding Pub/Sub topic. - - Keys are notification triggers. Supported keys are: - - - "all-triggers": Notify each time any of the supported - triggers occurs. - - "create-analysis": Notify each time an analysis is - created. - - "create-conversation": Notify each time a conversation is - created. - - "export-insights-data": Notify each time an export is - complete. - - "update-conversation": Notify each time a conversation is - updated via UpdateConversation. - - Values are Pub/Sub topics. The format of each Pub/Sub topic - is: projects/{project}/topics/{topic} - analysis_config (google.cloud.contact_center_insights_v1.types.Settings.AnalysisConfig): - Default analysis settings. - 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): - r"""Default configuration when creating Analyses in Insights. - - Attributes: - runtime_integration_analysis_percentage (float): - Percentage of conversations created using Dialogflow runtime - integration to analyze automatically, between [0, 100]. - upload_conversation_analysis_percentage (float): - Percentage of conversations created using the - UploadConversation endpoint to analyze automatically, - between [0, 100]. - annotator_selector (google.cloud.contact_center_insights_v1.types.AnnotatorSelector): - To select the annotators to run and the - phrase matchers to use (if any). If not - specified, all annotators will be run. - """ - - runtime_integration_analysis_percentage: float = proto.Field( - proto.DOUBLE, - number=1, - ) - upload_conversation_analysis_percentage: float = proto.Field( - proto.DOUBLE, - number=6, - ) - annotator_selector: 'AnnotatorSelector' = proto.Field( - proto.MESSAGE, - number=5, - message='AnnotatorSelector', - ) - - name: str = proto.Field( - proto.STRING, - number=1, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - language_code: str = proto.Field( - proto.STRING, - number=4, - ) - conversation_ttl: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=5, - message=duration_pb2.Duration, - ) - pubsub_notification_settings: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=6, - ) - analysis_config: AnalysisConfig = proto.Field( - proto.MESSAGE, - number=7, - message=AnalysisConfig, - ) - redaction_config: 'RedactionConfig' = proto.Field( - proto.MESSAGE, - number=10, - message='RedactionConfig', - ) - speech_config: 'SpeechConfig' = proto.Field( - proto.MESSAGE, - number=11, - message='SpeechConfig', - ) - - -class RedactionConfig(proto.Message): - r"""DLP resources used for redaction while ingesting - conversations. - - Attributes: - deidentify_template (str): - The fully-qualified DLP deidentify template resource name. - Format: - ``projects/{project}/deidentifyTemplates/{template}`` - inspect_template (str): - The fully-qualified DLP inspect template resource name. - Format: - ``projects/{project}/locations/{location}/inspectTemplates/{template}`` - """ - - deidentify_template: str = proto.Field( - proto.STRING, - number=1, - ) - inspect_template: str = proto.Field( - proto.STRING, - number=2, - ) - - -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. - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - article_suggestion (google.cloud.contact_center_insights_v1.types.ArticleSuggestionData): - Agent Assist Article Suggestion data. - - This field is a member of `oneof`_ ``data``. - faq_answer (google.cloud.contact_center_insights_v1.types.FaqAnswerData): - Agent Assist FAQ answer data. - - This field is a member of `oneof`_ ``data``. - smart_reply (google.cloud.contact_center_insights_v1.types.SmartReplyData): - Agent Assist Smart Reply data. - - This field is a member of `oneof`_ ``data``. - smart_compose_suggestion (google.cloud.contact_center_insights_v1.types.SmartComposeSuggestionData): - Agent Assist Smart Compose suggestion data. - - This field is a member of `oneof`_ ``data``. - dialogflow_interaction (google.cloud.contact_center_insights_v1.types.DialogflowInteractionData): - Dialogflow interaction data. - - This field is a member of `oneof`_ ``data``. - conversation_summarization_suggestion (google.cloud.contact_center_insights_v1.types.ConversationSummarizationSuggestionData): - Conversation summarization suggestion data. - - This field is a member of `oneof`_ ``data``. - annotation_id (str): - The unique identifier of the annotation. Format: - projects/{project}/locations/{location}/conversationDatasets/{dataset}/conversationDataItems/{data_item}/conversationAnnotations/{annotation} - create_time (google.protobuf.timestamp_pb2.Timestamp): - The time at which this annotation was - created. - start_boundary (google.cloud.contact_center_insights_v1.types.AnnotationBoundary): - The boundary in the conversation where the - annotation starts, inclusive. - end_boundary (google.cloud.contact_center_insights_v1.types.AnnotationBoundary): - The boundary in the conversation where the - annotation ends, inclusive. - answer_feedback (google.cloud.contact_center_insights_v1.types.AnswerFeedback): - The feedback that the customer has about the answer in - ``data``. - """ - - article_suggestion: 'ArticleSuggestionData' = proto.Field( - proto.MESSAGE, - number=6, - oneof='data', - message='ArticleSuggestionData', - ) - faq_answer: 'FaqAnswerData' = proto.Field( - proto.MESSAGE, - number=7, - oneof='data', - message='FaqAnswerData', - ) - smart_reply: 'SmartReplyData' = proto.Field( - proto.MESSAGE, - number=8, - oneof='data', - message='SmartReplyData', - ) - smart_compose_suggestion: 'SmartComposeSuggestionData' = proto.Field( - proto.MESSAGE, - number=9, - oneof='data', - message='SmartComposeSuggestionData', - ) - dialogflow_interaction: 'DialogflowInteractionData' = proto.Field( - proto.MESSAGE, - number=10, - oneof='data', - message='DialogflowInteractionData', - ) - conversation_summarization_suggestion: 'ConversationSummarizationSuggestionData' = proto.Field( - proto.MESSAGE, - number=12, - oneof='data', - message='ConversationSummarizationSuggestionData', - ) - annotation_id: str = proto.Field( - proto.STRING, - number=1, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - start_boundary: 'AnnotationBoundary' = proto.Field( - proto.MESSAGE, - number=3, - message='AnnotationBoundary', - ) - end_boundary: 'AnnotationBoundary' = proto.Field( - proto.MESSAGE, - number=4, - message='AnnotationBoundary', - ) - answer_feedback: 'AnswerFeedback' = proto.Field( - proto.MESSAGE, - number=5, - message='AnswerFeedback', - ) - - -class AnswerFeedback(proto.Message): - r"""The feedback that the customer has about a certain answer in - the conversation. - - Attributes: - correctness_level (google.cloud.contact_center_insights_v1.types.AnswerFeedback.CorrectnessLevel): - The correctness level of an answer. - clicked (bool): - Indicates whether an answer or item was - clicked by the human agent. - displayed (bool): - Indicates whether an answer or item was - displayed to the human agent in the agent - desktop UI. - """ - class CorrectnessLevel(proto.Enum): - r"""The correctness level of an answer. - - Values: - CORRECTNESS_LEVEL_UNSPECIFIED (0): - Correctness level unspecified. - NOT_CORRECT (1): - Answer is totally wrong. - PARTIALLY_CORRECT (2): - Answer is partially correct. - FULLY_CORRECT (3): - Answer is fully correct. - """ - CORRECTNESS_LEVEL_UNSPECIFIED = 0 - NOT_CORRECT = 1 - PARTIALLY_CORRECT = 2 - FULLY_CORRECT = 3 - - correctness_level: CorrectnessLevel = proto.Field( - proto.ENUM, - number=1, - enum=CorrectnessLevel, - ) - clicked: bool = proto.Field( - proto.BOOL, - number=2, - ) - displayed: bool = proto.Field( - proto.BOOL, - number=3, - ) - - -class ArticleSuggestionData(proto.Message): - r"""Agent Assist Article Suggestion data. - - Attributes: - title (str): - Article title. - uri (str): - Article URI. - confidence_score (float): - The system's confidence score that this - article is a good match for this conversation, - ranging from 0.0 (completely uncertain) to 1.0 - (completely certain). - metadata (MutableMapping[str, str]): - Map that contains metadata about the Article - Suggestion and the document that it originates - from. - query_record (str): - The name of the answer record. Format: - projects/{project}/locations/{location}/answerRecords/{answer_record} - source (str): - The knowledge document that this answer was extracted from. - Format: - projects/{project}/knowledgeBases/{knowledge_base}/documents/{document} - """ - - title: str = proto.Field( - proto.STRING, - number=1, - ) - uri: str = proto.Field( - proto.STRING, - number=2, - ) - confidence_score: float = proto.Field( - proto.FLOAT, - number=3, - ) - metadata: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=4, - ) - query_record: str = proto.Field( - proto.STRING, - number=5, - ) - source: str = proto.Field( - proto.STRING, - number=6, - ) - - -class FaqAnswerData(proto.Message): - r"""Agent Assist frequently-asked-question answer data. - - Attributes: - answer (str): - The piece of text from the ``source`` knowledge base - document. - confidence_score (float): - The system's confidence score that this - answer is a good match for this conversation, - ranging from 0.0 (completely uncertain) to 1.0 - (completely certain). - question (str): - The corresponding FAQ question. - metadata (MutableMapping[str, str]): - Map that contains metadata about the FAQ - answer and the document that it originates from. - query_record (str): - The name of the answer record. Format: - projects/{project}/locations/{location}/answerRecords/{answer_record} - source (str): - The knowledge document that this answer was extracted from. - Format: - projects/{project}/knowledgeBases/{knowledge_base}/documents/{document}. - """ - - answer: str = proto.Field( - proto.STRING, - number=1, - ) - confidence_score: float = proto.Field( - proto.FLOAT, - number=2, - ) - question: str = proto.Field( - proto.STRING, - number=3, - ) - metadata: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=4, - ) - query_record: str = proto.Field( - proto.STRING, - number=5, - ) - source: str = proto.Field( - proto.STRING, - number=6, - ) - - -class SmartReplyData(proto.Message): - r"""Agent Assist Smart Reply data. - - Attributes: - reply (str): - The content of the reply. - confidence_score (float): - The system's confidence score that this reply - is a good match for this conversation, ranging - from 0.0 (completely uncertain) to 1.0 - (completely certain). - metadata (MutableMapping[str, str]): - Map that contains metadata about the Smart - Reply and the document from which it originates. - query_record (str): - The name of the answer record. Format: - projects/{project}/locations/{location}/answerRecords/{answer_record} - """ - - reply: str = proto.Field( - proto.STRING, - number=1, - ) - confidence_score: float = proto.Field( - proto.DOUBLE, - number=2, - ) - metadata: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=3, - ) - query_record: str = proto.Field( - proto.STRING, - number=4, - ) - - -class SmartComposeSuggestionData(proto.Message): - r"""Agent Assist Smart Compose suggestion data. - - Attributes: - suggestion (str): - The content of the suggestion. - confidence_score (float): - The system's confidence score that this - suggestion is a good match for this - conversation, ranging from 0.0 (completely - uncertain) to 1.0 (completely certain). - metadata (MutableMapping[str, str]): - Map that contains metadata about the Smart - Compose suggestion and the document from which - it originates. - query_record (str): - The name of the answer record. Format: - projects/{project}/locations/{location}/answerRecords/{answer_record} - """ - - suggestion: str = proto.Field( - proto.STRING, - number=1, - ) - confidence_score: float = proto.Field( - proto.DOUBLE, - number=2, - ) - metadata: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=3, - ) - query_record: str = proto.Field( - proto.STRING, - number=4, - ) - - -class DialogflowInteractionData(proto.Message): - r"""Dialogflow interaction data. - - Attributes: - dialogflow_intent_id (str): - The Dialogflow intent resource path. Format: - projects/{project}/agent/{agent}/intents/{intent} - confidence (float): - The confidence of the match ranging from 0.0 - (completely uncertain) to 1.0 (completely - certain). - """ - - dialogflow_intent_id: str = proto.Field( - proto.STRING, - number=1, - ) - confidence: float = proto.Field( - proto.FLOAT, - number=2, - ) - - -class ConversationSummarizationSuggestionData(proto.Message): - r"""Conversation summarization suggestion data. - - Attributes: - text (str): - The summarization content that is - concatenated into one string. - text_sections (MutableMapping[str, str]): - The summarization content that is divided - into sections. The key is the section's name and - the value is the section's content. There is no - specific format for the key or value. - confidence (float): - The confidence score of the summarization. - metadata (MutableMapping[str, str]): - A map that contains metadata about the - summarization and the document from which it - originates. - answer_record (str): - The name of the answer record. Format: - projects/{project}/locations/{location}/answerRecords/{answer_record} - conversation_model (str): - The name of the model that generates this summary. Format: - projects/{project}/locations/{location}/conversationModels/{conversation_model} - """ - - text: str = proto.Field( - proto.STRING, - number=1, - ) - text_sections: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=5, - ) - confidence: float = proto.Field( - proto.FLOAT, - number=2, - ) - metadata: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=3, - ) - answer_record: str = proto.Field( - proto.STRING, - number=4, - ) - conversation_model: str = proto.Field( - proto.STRING, - number=6, - ) - - -class ConversationParticipant(proto.Message): - r"""The call participant speaking for a given utterance. - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - dialogflow_participant_name (str): - The name of the participant provided by - Dialogflow. Format: - projects/{project}/locations/{location}/conversations/{conversation}/participants/{participant} - - This field is a member of `oneof`_ ``participant``. - user_id (str): - A user-specified ID representing the - participant. - - This field is a member of `oneof`_ ``participant``. - dialogflow_participant (str): - Deprecated. Use ``dialogflow_participant_name`` instead. The - name of the Dialogflow participant. Format: - projects/{project}/locations/{location}/conversations/{conversation}/participants/{participant} - obfuscated_external_user_id (str): - Obfuscated user ID from Dialogflow. - role (google.cloud.contact_center_insights_v1.types.ConversationParticipant.Role): - The role of the participant. - """ - class Role(proto.Enum): - r"""The role of the participant. - - Values: - ROLE_UNSPECIFIED (0): - Participant's role is not set. - HUMAN_AGENT (1): - Participant is a human agent. - AUTOMATED_AGENT (2): - Participant is an automated agent. - END_USER (3): - Participant is an end user who conversed with - the contact center. - ANY_AGENT (4): - Participant is either a human or automated - agent. - """ - ROLE_UNSPECIFIED = 0 - HUMAN_AGENT = 1 - AUTOMATED_AGENT = 2 - END_USER = 3 - ANY_AGENT = 4 - - dialogflow_participant_name: str = proto.Field( - proto.STRING, - number=5, - oneof='participant', - ) - user_id: str = proto.Field( - proto.STRING, - number=6, - oneof='participant', - ) - dialogflow_participant: str = proto.Field( - proto.STRING, - number=1, - ) - obfuscated_external_user_id: str = proto.Field( - proto.STRING, - number=3, - ) - role: Role = proto.Field( - proto.ENUM, - number=2, - enum=Role, - ) - - -class View(proto.Message): - r"""The View resource. - - Attributes: - name (str): - Immutable. The resource name of the view. - Format: - - projects/{project}/locations/{location}/views/{view} - display_name (str): - The human-readable display name of the view. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which this view was - created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The most recent time at which - the view was updated. - value (str): - String with specific view properties, must be - non-empty. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - display_name: str = proto.Field( - proto.STRING, - number=2, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.Timestamp, - ) - value: str = proto.Field( - proto.STRING, - number=5, - ) - - -class AnnotatorSelector(proto.Message): - r"""Selector of all available annotators and phrase matchers to - run. - - Attributes: - run_interruption_annotator (bool): - Whether to run the interruption annotator. - run_silence_annotator (bool): - Whether to run the silence annotator. - run_phrase_matcher_annotator (bool): - Whether to run the active phrase matcher - annotator(s). - phrase_matchers (MutableSequence[str]): - The list of phrase matchers to run. If not provided, all - active phrase matchers will be used. If inactive phrase - matchers are provided, they will not be used. Phrase - matchers will be run only if run_phrase_matcher_annotator is - set to true. Format: - projects/{project}/locations/{location}/phraseMatchers/{phrase_matcher} - run_sentiment_annotator (bool): - Whether to run the sentiment annotator. - run_entity_annotator (bool): - Whether to run the entity annotator. - run_intent_annotator (bool): - Whether to run the intent annotator. - run_issue_model_annotator (bool): - Whether to run the issue model annotator. A - model should have already been deployed for this - to take effect. - issue_models (MutableSequence[str]): - The issue model to run. If not provided, the most recently - deployed topic model will be used. The provided issue model - will only be used for inference if the issue model is - deployed and if run_issue_model_annotator is set to true. If - more than one issue model is provided, only the first - provided issue model will be used for inference. - run_summarization_annotator (bool): - Whether to run the summarization annotator. - summarization_config (google.cloud.contact_center_insights_v1.types.AnnotatorSelector.SummarizationConfig): - Configuration for the summarization - annotator. - """ - - class SummarizationConfig(proto.Message): - r"""Configuration for summarization. - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - conversation_profile (str): - Resource name of the Dialogflow conversation profile. - Format: - projects/{project}/locations/{location}/conversationProfiles/{conversation_profile} - - This field is a member of `oneof`_ ``model_source``. - summarization_model (google.cloud.contact_center_insights_v1.types.AnnotatorSelector.SummarizationConfig.SummarizationModel): - Default summarization model to be used. - - This field is a member of `oneof`_ ``model_source``. - """ - class SummarizationModel(proto.Enum): - r"""Summarization model to use, if ``conversation_profile`` is not used. - - Values: - SUMMARIZATION_MODEL_UNSPECIFIED (0): - Unspecified summarization model. - BASELINE_MODEL (1): - The Insights baseline model. - """ - SUMMARIZATION_MODEL_UNSPECIFIED = 0 - BASELINE_MODEL = 1 - - conversation_profile: str = proto.Field( - proto.STRING, - number=1, - oneof='model_source', - ) - summarization_model: 'AnnotatorSelector.SummarizationConfig.SummarizationModel' = proto.Field( - proto.ENUM, - number=2, - oneof='model_source', - enum='AnnotatorSelector.SummarizationConfig.SummarizationModel', - ) - - run_interruption_annotator: bool = proto.Field( - proto.BOOL, - number=1, - ) - run_silence_annotator: bool = proto.Field( - proto.BOOL, - number=2, - ) - run_phrase_matcher_annotator: bool = proto.Field( - proto.BOOL, - number=3, - ) - phrase_matchers: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=4, - ) - run_sentiment_annotator: bool = proto.Field( - proto.BOOL, - number=5, - ) - run_entity_annotator: bool = proto.Field( - proto.BOOL, - number=6, - ) - run_intent_annotator: bool = proto.Field( - proto.BOOL, - number=7, - ) - run_issue_model_annotator: bool = proto.Field( - proto.BOOL, - number=8, - ) - issue_models: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=10, - ) - run_summarization_annotator: bool = proto.Field( - proto.BOOL, - number=9, - ) - summarization_config: SummarizationConfig = proto.Field( - proto.MESSAGE, - number=11, - message=SummarizationConfig, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/mypy.ini b/owl-bot-staging/google-cloud-contact-center-insights/v1/mypy.ini deleted file mode 100644 index 574c5aed394b..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.7 -namespace_packages = True diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/noxfile.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/noxfile.py deleted file mode 100644 index 0a250777705f..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/noxfile.py +++ /dev/null @@ -1,184 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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 os -import pathlib -import shutil -import subprocess -import sys - - -import nox # type: ignore - -ALL_PYTHON = [ - "3.7", - "3.8", - "3.9", - "3.10", - "3.11", -] - -CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() - -LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" -PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8") - -BLACK_VERSION = "black==22.3.0" -BLACK_PATHS = ["docs", "google", "tests", "samples", "noxfile.py", "setup.py"] -DEFAULT_PYTHON_VERSION = "3.11" - -nox.sessions = [ - "unit", - "cover", - "mypy", - "check_lower_bounds" - # exclude update_lower_bounds from default - "docs", - "blacken", - "lint", - "lint_setup_py", -] - -@nox.session(python=ALL_PYTHON) -def unit(session): - """Run the unit test suite.""" - - session.install('coverage', 'pytest', 'pytest-cov', 'pytest-asyncio', 'asyncmock; python_version < "3.8"') - session.install('-e', '.') - - session.run( - 'py.test', - '--quiet', - '--cov=google/cloud/contact_center_insights_v1/', - '--cov=tests/', - '--cov-config=.coveragerc', - '--cov-report=term', - '--cov-report=html', - os.path.join('tests', 'unit', ''.join(session.posargs)) - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def cover(session): - """Run the final coverage report. - This outputs the coverage report aggregating coverage from the unit - test runs (not system test runs), and then erases coverage data. - """ - session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=100") - - session.run("coverage", "erase") - - -@nox.session(python=ALL_PYTHON) -def mypy(session): - """Run the type checker.""" - session.install( - 'mypy', - 'types-requests', - 'types-protobuf' - ) - session.install('.') - session.run( - 'mypy', - '--explicit-package-bases', - 'google', - ) - - -@nox.session -def update_lower_bounds(session): - """Update lower bounds in constraints.txt to match setup.py""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'update', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - - -@nox.session -def check_lower_bounds(session): - """Check lower bounds in setup.py are reflected in constraints file""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'check', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def docs(session): - """Build the docs for this library.""" - - session.install("-e", ".") - session.install("sphinx==7.0.1", "alabaster", "recommonmark") - - shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) - session.run( - "sphinx-build", - "-W", # warnings as errors - "-T", # show full traceback on exception - "-N", # no colors - "-b", - "html", - "-d", - os.path.join("docs", "_build", "doctrees", ""), - os.path.join("docs", ""), - os.path.join("docs", "_build", "html", ""), - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def lint(session): - """Run linters. - - Returns a failure if the linters find linting errors or sufficiently - serious code quality issues. - """ - session.install("flake8", BLACK_VERSION) - session.run( - "black", - "--check", - *BLACK_PATHS, - ) - session.run("flake8", "google", "tests", "samples") - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def blacken(session): - """Run black. Format code to uniform standard.""" - session.install(BLACK_VERSION) - session.run( - "black", - *BLACK_PATHS, - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def lint_setup_py(session): - """Verify that setup.py is valid (including RST check).""" - session.install("docutils", "pygments") - session.run("python", "setup.py", "check", "--restructuredtext", "--strict") diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_async.py deleted file mode 100644 index 68cbb8faca8f..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_async.py +++ /dev/null @@ -1,58 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for BulkAnalyzeConversations -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_BulkAnalyzeConversations_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_bulk_analyze_conversations(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.BulkAnalyzeConversationsRequest( - parent="parent_value", - filter="filter_value", - analysis_percentage=0.20170000000000002, - ) - - # Make the request - operation = client.bulk_analyze_conversations(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_BulkAnalyzeConversations_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_sync.py deleted file mode 100644 index ceac1fb7f825..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_sync.py +++ /dev/null @@ -1,58 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for BulkAnalyzeConversations -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_BulkAnalyzeConversations_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_bulk_analyze_conversations(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.BulkAnalyzeConversationsRequest( - parent="parent_value", - filter="filter_value", - analysis_percentage=0.20170000000000002, - ) - - # Make the request - operation = client.bulk_analyze_conversations(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_BulkAnalyzeConversations_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_async.py deleted file mode 100644 index 4b029eb09247..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CalculateIssueModelStats -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_CalculateIssueModelStats_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_calculate_issue_model_stats(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CalculateIssueModelStatsRequest( - issue_model="issue_model_value", - ) - - # Make the request - response = await client.calculate_issue_model_stats(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_CalculateIssueModelStats_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_sync.py deleted file mode 100644 index a801c0974a17..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CalculateIssueModelStats -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_CalculateIssueModelStats_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_calculate_issue_model_stats(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CalculateIssueModelStatsRequest( - issue_model="issue_model_value", - ) - - # Make the request - response = client.calculate_issue_model_stats(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_CalculateIssueModelStats_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_async.py deleted file mode 100644 index eba9f4023e94..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CalculateStats -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_CalculateStats_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_calculate_stats(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CalculateStatsRequest( - location="location_value", - ) - - # Make the request - response = await client.calculate_stats(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_CalculateStats_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_sync.py deleted file mode 100644 index 852d0c9a8b6c..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CalculateStats -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_CalculateStats_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_calculate_stats(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CalculateStatsRequest( - location="location_value", - ) - - # Make the request - response = client.calculate_stats(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_CalculateStats_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_async.py deleted file mode 100644 index bcd0bce51d52..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateAnalysis -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysis_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_create_analysis(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CreateAnalysisRequest( - parent="parent_value", - ) - - # Make the request - operation = client.create_analysis(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysis_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_sync.py deleted file mode 100644 index 7783a422e609..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_analysis_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateAnalysis -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysis_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_create_analysis(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CreateAnalysisRequest( - parent="parent_value", - ) - - # Make the request - operation = client.create_analysis(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysis_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_conversation_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_conversation_async.py deleted file mode 100644 index c12d420c9c35..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_conversation_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateConversation -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateConversation_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_create_conversation(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CreateConversationRequest( - parent="parent_value", - ) - - # Make the request - response = await client.create_conversation(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateConversation_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_conversation_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_conversation_sync.py deleted file mode 100644 index 3bdfd048c222..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_conversation_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateConversation -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateConversation_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_create_conversation(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CreateConversationRequest( - parent="parent_value", - ) - - # Make the request - response = client.create_conversation(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateConversation_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_async.py deleted file mode 100644 index d83009c8eedf..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateIssueModel -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateIssueModel_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_create_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CreateIssueModelRequest( - parent="parent_value", - ) - - # Make the request - operation = client.create_issue_model(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateIssueModel_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_sync.py deleted file mode 100644 index 4ce5d853cad2..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateIssueModel -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateIssueModel_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_create_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CreateIssueModelRequest( - parent="parent_value", - ) - - # Make the request - operation = client.create_issue_model(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateIssueModel_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_async.py deleted file mode 100644 index 0f5f4f29898d..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreatePhraseMatcher -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreatePhraseMatcher_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_create_phrase_matcher(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - phrase_matcher = contact_center_insights_v1.PhraseMatcher() - phrase_matcher.type_ = "ANY_OF" - - request = contact_center_insights_v1.CreatePhraseMatcherRequest( - parent="parent_value", - phrase_matcher=phrase_matcher, - ) - - # Make the request - response = await client.create_phrase_matcher(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreatePhraseMatcher_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_sync.py deleted file mode 100644 index 6d7c68bd7449..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreatePhraseMatcher -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreatePhraseMatcher_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_create_phrase_matcher(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - phrase_matcher = contact_center_insights_v1.PhraseMatcher() - phrase_matcher.type_ = "ANY_OF" - - request = contact_center_insights_v1.CreatePhraseMatcherRequest( - parent="parent_value", - phrase_matcher=phrase_matcher, - ) - - # Make the request - response = client.create_phrase_matcher(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreatePhraseMatcher_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_view_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_view_async.py deleted file mode 100644 index 9873dbea6e4a..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_view_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateView -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateView_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_create_view(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CreateViewRequest( - parent="parent_value", - ) - - # Make the request - response = await client.create_view(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateView_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_view_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_view_sync.py deleted file mode 100644 index 6141541f6493..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_create_view_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateView -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_CreateView_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_create_view(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.CreateViewRequest( - parent="parent_value", - ) - - # Make the request - response = client.create_view(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_CreateView_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_async.py deleted file mode 100644 index 79314602b54a..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_async.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteAnalysis -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysis_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_delete_analysis(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeleteAnalysisRequest( - name="name_value", - ) - - # Make the request - await client.delete_analysis(request=request) - - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysis_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_sync.py deleted file mode 100644 index d4a876727da9..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_sync.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteAnalysis -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysis_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_delete_analysis(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeleteAnalysisRequest( - name="name_value", - ) - - # Make the request - client.delete_analysis(request=request) - - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysis_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_async.py deleted file mode 100644 index 6640928d9e03..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_async.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteConversation -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteConversation_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_delete_conversation(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeleteConversationRequest( - name="name_value", - ) - - # Make the request - await client.delete_conversation(request=request) - - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteConversation_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_sync.py deleted file mode 100644 index 8222cf303ec4..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_sync.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteConversation -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteConversation_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_delete_conversation(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeleteConversationRequest( - name="name_value", - ) - - # Make the request - client.delete_conversation(request=request) - - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteConversation_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_async.py deleted file mode 100644 index 2fa8538c91ec..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_async.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteIssue -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssue_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_delete_issue(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeleteIssueRequest( - name="name_value", - ) - - # Make the request - await client.delete_issue(request=request) - - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssue_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_async.py deleted file mode 100644 index 73bfc785d295..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteIssueModel -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssueModel_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_delete_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeleteIssueModelRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_issue_model(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssueModel_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_sync.py deleted file mode 100644 index 43b681e40edb..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteIssueModel -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssueModel_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_delete_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeleteIssueModelRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_issue_model(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssueModel_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_sync.py deleted file mode 100644 index 1a9559812956..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_issue_sync.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteIssue -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssue_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_delete_issue(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeleteIssueRequest( - name="name_value", - ) - - # Make the request - client.delete_issue(request=request) - - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssue_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_async.py deleted file mode 100644 index 4424e648a601..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_async.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeletePhraseMatcher -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeletePhraseMatcher_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_delete_phrase_matcher(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeletePhraseMatcherRequest( - name="name_value", - ) - - # Make the request - await client.delete_phrase_matcher(request=request) - - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeletePhraseMatcher_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_sync.py deleted file mode 100644 index c0ac075cca70..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_sync.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeletePhraseMatcher -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeletePhraseMatcher_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_delete_phrase_matcher(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeletePhraseMatcherRequest( - name="name_value", - ) - - # Make the request - client.delete_phrase_matcher(request=request) - - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeletePhraseMatcher_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_view_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_view_async.py deleted file mode 100644 index 1d1af8720171..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_view_async.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteView -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteView_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_delete_view(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeleteViewRequest( - name="name_value", - ) - - # Make the request - await client.delete_view(request=request) - - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteView_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_view_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_view_sync.py deleted file mode 100644 index 57aa09a8a4b4..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_delete_view_sync.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteView -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeleteView_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_delete_view(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeleteViewRequest( - name="name_value", - ) - - # Make the request - client.delete_view(request=request) - - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeleteView_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_async.py deleted file mode 100644 index de05e6505002..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeployIssueModel -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeployIssueModel_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_deploy_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeployIssueModelRequest( - name="name_value", - ) - - # Make the request - operation = client.deploy_issue_model(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeployIssueModel_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_sync.py deleted file mode 100644 index 32bbac86872d..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeployIssueModel -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_DeployIssueModel_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_deploy_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.DeployIssueModelRequest( - name="name_value", - ) - - # Make the request - operation = client.deploy_issue_model(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_DeployIssueModel_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_async.py deleted file mode 100644 index 926818d9619b..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_async.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ExportInsightsData -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_ExportInsightsData_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_export_insights_data(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - big_query_destination = contact_center_insights_v1.BigQueryDestination() - big_query_destination.dataset = "dataset_value" - - request = contact_center_insights_v1.ExportInsightsDataRequest( - big_query_destination=big_query_destination, - parent="parent_value", - ) - - # Make the request - operation = client.export_insights_data(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_ExportInsightsData_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_sync.py deleted file mode 100644 index 47d80c10c02b..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_sync.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ExportInsightsData -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_ExportInsightsData_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_export_insights_data(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - big_query_destination = contact_center_insights_v1.BigQueryDestination() - big_query_destination.dataset = "dataset_value" - - request = contact_center_insights_v1.ExportInsightsDataRequest( - big_query_destination=big_query_destination, - parent="parent_value", - ) - - # Make the request - operation = client.export_insights_data(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_ExportInsightsData_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_async.py deleted file mode 100644 index 19b879c57016..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetAnalysis -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysis_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_get_analysis(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetAnalysisRequest( - name="name_value", - ) - - # Make the request - response = await client.get_analysis(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysis_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_sync.py deleted file mode 100644 index da794ff3405a..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_analysis_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetAnalysis -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysis_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_get_analysis(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetAnalysisRequest( - name="name_value", - ) - - # Make the request - response = client.get_analysis(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysis_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_conversation_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_conversation_async.py deleted file mode 100644 index d0023912ab58..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_conversation_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetConversation -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetConversation_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_get_conversation(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetConversationRequest( - name="name_value", - ) - - # Make the request - response = await client.get_conversation(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetConversation_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_conversation_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_conversation_sync.py deleted file mode 100644 index 0cf65814d075..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_conversation_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetConversation -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetConversation_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_get_conversation(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetConversationRequest( - name="name_value", - ) - - # Make the request - response = client.get_conversation(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetConversation_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_async.py deleted file mode 100644 index 51423a5a0bf6..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetIssue -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetIssue_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_get_issue(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetIssueRequest( - name="name_value", - ) - - # Make the request - response = await client.get_issue(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetIssue_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_async.py deleted file mode 100644 index f58e9d3eb689..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetIssueModel -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetIssueModel_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_get_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetIssueModelRequest( - name="name_value", - ) - - # Make the request - response = await client.get_issue_model(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetIssueModel_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_sync.py deleted file mode 100644 index 8f602f7319b7..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetIssueModel -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetIssueModel_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_get_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetIssueModelRequest( - name="name_value", - ) - - # Make the request - response = client.get_issue_model(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetIssueModel_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_sync.py deleted file mode 100644 index 572ce1cd362c..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_issue_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetIssue -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetIssue_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_get_issue(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetIssueRequest( - name="name_value", - ) - - # Make the request - response = client.get_issue(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetIssue_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_async.py deleted file mode 100644 index 78bf70f71166..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetPhraseMatcher -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetPhraseMatcher_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_get_phrase_matcher(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetPhraseMatcherRequest( - name="name_value", - ) - - # Make the request - response = await client.get_phrase_matcher(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetPhraseMatcher_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_sync.py deleted file mode 100644 index 9473f7d6c2c5..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetPhraseMatcher -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetPhraseMatcher_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_get_phrase_matcher(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetPhraseMatcherRequest( - name="name_value", - ) - - # Make the request - response = client.get_phrase_matcher(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetPhraseMatcher_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_settings_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_settings_async.py deleted file mode 100644 index ab0789ab5a23..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_settings_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetSettings -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetSettings_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_get_settings(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetSettingsRequest( - name="name_value", - ) - - # Make the request - response = await client.get_settings(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetSettings_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_settings_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_settings_sync.py deleted file mode 100644 index 81d28e3ae3cf..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_settings_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetSettings -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetSettings_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_get_settings(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetSettingsRequest( - name="name_value", - ) - - # Make the request - response = client.get_settings(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetSettings_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_view_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_view_async.py deleted file mode 100644 index db108050140f..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_view_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetView -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetView_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_get_view(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetViewRequest( - name="name_value", - ) - - # Make the request - response = await client.get_view(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetView_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_view_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_view_sync.py deleted file mode 100644 index 320bd8d2ae32..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_get_view_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetView -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_GetView_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_get_view(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.GetViewRequest( - name="name_value", - ) - - # Make the request - response = client.get_view(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_GetView_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_async.py deleted file mode 100644 index 45293b7187e2..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_async.py +++ /dev/null @@ -1,64 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for IngestConversations -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_IngestConversations_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_ingest_conversations(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - gcs_source = contact_center_insights_v1.GcsSource() - gcs_source.bucket_uri = "bucket_uri_value" - - transcript_object_config = contact_center_insights_v1.TranscriptObjectConfig() - transcript_object_config.medium = "CHAT" - - request = contact_center_insights_v1.IngestConversationsRequest( - gcs_source=gcs_source, - transcript_object_config=transcript_object_config, - parent="parent_value", - ) - - # Make the request - operation = client.ingest_conversations(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_IngestConversations_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_sync.py deleted file mode 100644 index 978fe8194701..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_sync.py +++ /dev/null @@ -1,64 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for IngestConversations -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_IngestConversations_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_ingest_conversations(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - gcs_source = contact_center_insights_v1.GcsSource() - gcs_source.bucket_uri = "bucket_uri_value" - - transcript_object_config = contact_center_insights_v1.TranscriptObjectConfig() - transcript_object_config.medium = "CHAT" - - request = contact_center_insights_v1.IngestConversationsRequest( - gcs_source=gcs_source, - transcript_object_config=transcript_object_config, - parent="parent_value", - ) - - # Make the request - operation = client.ingest_conversations(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_IngestConversations_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analyses_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analyses_async.py deleted file mode 100644 index 510ceb61d226..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analyses_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListAnalyses -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalyses_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_list_analyses(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListAnalysesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_analyses(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalyses_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analyses_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analyses_sync.py deleted file mode 100644 index 73babf81c2ba..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_analyses_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListAnalyses -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalyses_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_list_analyses(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListAnalysesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_analyses(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalyses_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_conversations_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_conversations_async.py deleted file mode 100644 index 4afcfa9edee6..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_conversations_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListConversations -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListConversations_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_list_conversations(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListConversationsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_conversations(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListConversations_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_conversations_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_conversations_sync.py deleted file mode 100644 index 438e79d3c654..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_conversations_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListConversations -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListConversations_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_list_conversations(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListConversationsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_conversations(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListConversations_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_async.py deleted file mode 100644 index 4c17eb81986f..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListIssueModels -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListIssueModels_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_list_issue_models(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListIssueModelsRequest( - parent="parent_value", - ) - - # Make the request - response = await client.list_issue_models(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListIssueModels_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_sync.py deleted file mode 100644 index da6334511189..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListIssueModels -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListIssueModels_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_list_issue_models(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListIssueModelsRequest( - parent="parent_value", - ) - - # Make the request - response = client.list_issue_models(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListIssueModels_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issues_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issues_async.py deleted file mode 100644 index f884ef647b62..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issues_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListIssues -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListIssues_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_list_issues(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListIssuesRequest( - parent="parent_value", - ) - - # Make the request - response = await client.list_issues(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListIssues_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issues_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issues_sync.py deleted file mode 100644 index 879da47d32ae..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_issues_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListIssues -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListIssues_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_list_issues(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListIssuesRequest( - parent="parent_value", - ) - - # Make the request - response = client.list_issues(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListIssues_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_async.py deleted file mode 100644 index 5115bfcae255..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListPhraseMatchers -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListPhraseMatchers_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_list_phrase_matchers(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListPhraseMatchersRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_phrase_matchers(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListPhraseMatchers_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_sync.py deleted file mode 100644 index e0d0140d8804..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListPhraseMatchers -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListPhraseMatchers_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_list_phrase_matchers(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListPhraseMatchersRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_phrase_matchers(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListPhraseMatchers_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_views_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_views_async.py deleted file mode 100644 index b84905604b80..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_views_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListViews -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListViews_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_list_views(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListViewsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_views(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListViews_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_views_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_views_sync.py deleted file mode 100644 index 421bdeeaa421..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_list_views_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListViews -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_ListViews_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_list_views(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.ListViewsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_views(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_ListViews_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_async.py deleted file mode 100644 index dcae28aaa7a7..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UndeployIssueModel -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_UndeployIssueModel_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_undeploy_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UndeployIssueModelRequest( - name="name_value", - ) - - # Make the request - operation = client.undeploy_issue_model(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_UndeployIssueModel_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_sync.py deleted file mode 100644 index 2499e8463f97..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UndeployIssueModel -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_UndeployIssueModel_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_undeploy_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UndeployIssueModelRequest( - name="name_value", - ) - - # Make the request - operation = client.undeploy_issue_model(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_UndeployIssueModel_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_conversation_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_conversation_async.py deleted file mode 100644 index bad2357420be..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_conversation_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateConversation -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateConversation_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_update_conversation(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UpdateConversationRequest( - ) - - # Make the request - response = await client.update_conversation(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateConversation_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_conversation_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_conversation_sync.py deleted file mode 100644 index a05422e0381a..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_conversation_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateConversation -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateConversation_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_update_conversation(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UpdateConversationRequest( - ) - - # Make the request - response = client.update_conversation(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateConversation_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_async.py deleted file mode 100644 index aed4214ee18f..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateIssue -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssue_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_update_issue(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UpdateIssueRequest( - ) - - # Make the request - response = await client.update_issue(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssue_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_async.py deleted file mode 100644 index 2589c1695f08..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateIssueModel -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssueModel_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_update_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UpdateIssueModelRequest( - ) - - # Make the request - response = await client.update_issue_model(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssueModel_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_sync.py deleted file mode 100644 index eb83e74bc68d..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateIssueModel -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssueModel_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_update_issue_model(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UpdateIssueModelRequest( - ) - - # Make the request - response = client.update_issue_model(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssueModel_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_sync.py deleted file mode 100644 index 25946b42b8c2..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_issue_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateIssue -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssue_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_update_issue(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UpdateIssueRequest( - ) - - # Make the request - response = client.update_issue(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssue_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_async.py deleted file mode 100644 index 61a9c0c624b2..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_async.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdatePhraseMatcher -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdatePhraseMatcher_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_update_phrase_matcher(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - phrase_matcher = contact_center_insights_v1.PhraseMatcher() - phrase_matcher.type_ = "ANY_OF" - - request = contact_center_insights_v1.UpdatePhraseMatcherRequest( - phrase_matcher=phrase_matcher, - ) - - # Make the request - response = await client.update_phrase_matcher(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdatePhraseMatcher_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_sync.py deleted file mode 100644 index f3fcacb9cd8c..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_sync.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdatePhraseMatcher -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdatePhraseMatcher_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_update_phrase_matcher(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - phrase_matcher = contact_center_insights_v1.PhraseMatcher() - phrase_matcher.type_ = "ANY_OF" - - request = contact_center_insights_v1.UpdatePhraseMatcherRequest( - phrase_matcher=phrase_matcher, - ) - - # Make the request - response = client.update_phrase_matcher(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdatePhraseMatcher_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_settings_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_settings_async.py deleted file mode 100644 index 1b5b362be1a2..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_settings_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateSettings -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateSettings_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_update_settings(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UpdateSettingsRequest( - ) - - # Make the request - response = await client.update_settings(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateSettings_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_settings_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_settings_sync.py deleted file mode 100644 index 55ff02c2a757..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_settings_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateSettings -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateSettings_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_update_settings(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UpdateSettingsRequest( - ) - - # Make the request - response = client.update_settings(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateSettings_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_view_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_view_async.py deleted file mode 100644 index 9191f182b1f7..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_view_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateView -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateView_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_update_view(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UpdateViewRequest( - ) - - # Make the request - response = await client.update_view(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateView_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_view_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_view_sync.py deleted file mode 100644 index 930c18e183a1..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_update_view_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateView -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_UpdateView_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_update_view(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UpdateViewRequest( - ) - - # Make the request - response = client.update_view(request=request) - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_UpdateView_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_async.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_async.py deleted file mode 100644 index 379c9766dadc..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UploadConversation -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_UploadConversation_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -async def sample_upload_conversation(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsAsyncClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UploadConversationRequest( - parent="parent_value", - ) - - # Make the request - operation = client.upload_conversation(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_UploadConversation_async] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_sync.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_sync.py deleted file mode 100644 index 6d7fcac3ed7a..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UploadConversation -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-contact-center-insights - - -# [START contactcenterinsights_v1_generated_ContactCenterInsights_UploadConversation_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud import contact_center_insights_v1 - - -def sample_upload_conversation(): - # Create a client - client = contact_center_insights_v1.ContactCenterInsightsClient() - - # Initialize request argument(s) - request = contact_center_insights_v1.UploadConversationRequest( - parent="parent_value", - ) - - # Make the request - operation = client.upload_conversation(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END contactcenterinsights_v1_generated_ContactCenterInsights_UploadConversation_sync] diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/snippet_metadata_google.cloud.contactcenterinsights.v1.json b/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/snippet_metadata_google.cloud.contactcenterinsights.v1.json deleted file mode 100644 index c3e9d3df64ac..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/samples/generated_samples/snippet_metadata_google.cloud.contactcenterinsights.v1.json +++ /dev/null @@ -1,6207 +0,0 @@ -{ - "clientLibrary": { - "apis": [ - { - "id": "google.cloud.contactcenterinsights.v1", - "version": "v1" - } - ], - "language": "PYTHON", - "name": "google-cloud-contact-center-insights", - "version": "0.1.0" - }, - "snippets": [ - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.bulk_analyze_conversations", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.BulkAnalyzeConversations", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "BulkAnalyzeConversations" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.BulkAnalyzeConversationsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "filter", - "type": "str" - }, - { - "name": "analysis_percentage", - "type": "float" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "bulk_analyze_conversations" - }, - "description": "Sample for BulkAnalyzeConversations", - "file": "contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_BulkAnalyzeConversations_async", - "segments": [ - { - "end": 57, - "start": 27, - "type": "FULL" - }, - { - "end": 57, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 47, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 54, - "start": 48, - "type": "REQUEST_EXECUTION" - }, - { - "end": 58, - "start": 55, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.bulk_analyze_conversations", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.BulkAnalyzeConversations", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "BulkAnalyzeConversations" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.BulkAnalyzeConversationsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "filter", - "type": "str" - }, - { - "name": "analysis_percentage", - "type": "float" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "bulk_analyze_conversations" - }, - "description": "Sample for BulkAnalyzeConversations", - "file": "contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_BulkAnalyzeConversations_sync", - "segments": [ - { - "end": 57, - "start": 27, - "type": "FULL" - }, - { - "end": 57, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 47, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 54, - "start": 48, - "type": "REQUEST_EXECUTION" - }, - { - "end": 58, - "start": 55, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_bulk_analyze_conversations_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.calculate_issue_model_stats", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CalculateIssueModelStats", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "CalculateIssueModelStats" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsRequest" - }, - { - "name": "issue_model", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsResponse", - "shortName": "calculate_issue_model_stats" - }, - "description": "Sample for CalculateIssueModelStats", - "file": "contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CalculateIssueModelStats_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.calculate_issue_model_stats", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CalculateIssueModelStats", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "CalculateIssueModelStats" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsRequest" - }, - { - "name": "issue_model", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.CalculateIssueModelStatsResponse", - "shortName": "calculate_issue_model_stats" - }, - "description": "Sample for CalculateIssueModelStats", - "file": "contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CalculateIssueModelStats_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_calculate_issue_model_stats_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.calculate_stats", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CalculateStats", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "CalculateStats" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CalculateStatsRequest" - }, - { - "name": "location", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.CalculateStatsResponse", - "shortName": "calculate_stats" - }, - "description": "Sample for CalculateStats", - "file": "contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CalculateStats_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.calculate_stats", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CalculateStats", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "CalculateStats" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CalculateStatsRequest" - }, - { - "name": "location", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.CalculateStatsResponse", - "shortName": "calculate_stats" - }, - "description": "Sample for CalculateStats", - "file": "contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CalculateStats_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_calculate_stats_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_analysis", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateAnalysis", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "CreateAnalysis" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CreateAnalysisRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "analysis", - "type": "google.cloud.contact_center_insights_v1.types.Analysis" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_analysis" - }, - "description": "Sample for CreateAnalysis", - "file": "contactcenterinsights_v1_generated_contact_center_insights_create_analysis_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysis_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_create_analysis_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_analysis", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateAnalysis", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "CreateAnalysis" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CreateAnalysisRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "analysis", - "type": "google.cloud.contact_center_insights_v1.types.Analysis" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_analysis" - }, - "description": "Sample for CreateAnalysis", - "file": "contactcenterinsights_v1_generated_contact_center_insights_create_analysis_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateAnalysis_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_create_analysis_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_conversation", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateConversation", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "CreateConversation" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CreateConversationRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "conversation", - "type": "google.cloud.contact_center_insights_v1.types.Conversation" - }, - { - "name": "conversation_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", - "shortName": "create_conversation" - }, - "description": "Sample for CreateConversation", - "file": "contactcenterinsights_v1_generated_contact_center_insights_create_conversation_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateConversation_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_create_conversation_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_conversation", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateConversation", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "CreateConversation" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CreateConversationRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "conversation", - "type": "google.cloud.contact_center_insights_v1.types.Conversation" - }, - { - "name": "conversation_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", - "shortName": "create_conversation" - }, - "description": "Sample for CreateConversation", - "file": "contactcenterinsights_v1_generated_contact_center_insights_create_conversation_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateConversation_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_create_conversation_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_issue_model", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateIssueModel", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "CreateIssueModel" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CreateIssueModelRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "issue_model", - "type": "google.cloud.contact_center_insights_v1.types.IssueModel" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_issue_model" - }, - "description": "Sample for CreateIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateIssueModel_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_issue_model", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateIssueModel", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "CreateIssueModel" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CreateIssueModelRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "issue_model", - "type": "google.cloud.contact_center_insights_v1.types.IssueModel" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_issue_model" - }, - "description": "Sample for CreateIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateIssueModel_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_create_issue_model_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_phrase_matcher", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreatePhraseMatcher", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "CreatePhraseMatcher" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CreatePhraseMatcherRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "phrase_matcher", - "type": "google.cloud.contact_center_insights_v1.types.PhraseMatcher" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", - "shortName": "create_phrase_matcher" - }, - "description": "Sample for CreatePhraseMatcher", - "file": "contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreatePhraseMatcher_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_phrase_matcher", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreatePhraseMatcher", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "CreatePhraseMatcher" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CreatePhraseMatcherRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "phrase_matcher", - "type": "google.cloud.contact_center_insights_v1.types.PhraseMatcher" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", - "shortName": "create_phrase_matcher" - }, - "description": "Sample for CreatePhraseMatcher", - "file": "contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreatePhraseMatcher_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_create_phrase_matcher_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.create_view", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateView", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "CreateView" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CreateViewRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "view", - "type": "google.cloud.contact_center_insights_v1.types.View" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.View", - "shortName": "create_view" - }, - "description": "Sample for CreateView", - "file": "contactcenterinsights_v1_generated_contact_center_insights_create_view_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateView_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_create_view_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.create_view", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.CreateView", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "CreateView" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.CreateViewRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "view", - "type": "google.cloud.contact_center_insights_v1.types.View" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.View", - "shortName": "create_view" - }, - "description": "Sample for CreateView", - "file": "contactcenterinsights_v1_generated_contact_center_insights_create_view_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_CreateView_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_create_view_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_analysis", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteAnalysis", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "DeleteAnalysis" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeleteAnalysisRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "shortName": "delete_analysis" - }, - "description": "Sample for DeleteAnalysis", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysis_async", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_analysis", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteAnalysis", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "DeleteAnalysis" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeleteAnalysisRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "shortName": "delete_analysis" - }, - "description": "Sample for DeleteAnalysis", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteAnalysis_sync", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_analysis_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_conversation", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteConversation", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "DeleteConversation" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeleteConversationRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "shortName": "delete_conversation" - }, - "description": "Sample for DeleteConversation", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteConversation_async", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_conversation", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteConversation", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "DeleteConversation" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeleteConversationRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "shortName": "delete_conversation" - }, - "description": "Sample for DeleteConversation", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteConversation_sync", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_conversation_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_issue_model", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteIssueModel", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "DeleteIssueModel" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeleteIssueModelRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_issue_model" - }, - "description": "Sample for DeleteIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssueModel_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_issue_model", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteIssueModel", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "DeleteIssueModel" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeleteIssueModelRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_issue_model" - }, - "description": "Sample for DeleteIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssueModel_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_model_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_issue", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteIssue", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "DeleteIssue" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeleteIssueRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "shortName": "delete_issue" - }, - "description": "Sample for DeleteIssue", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssue_async", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_issue", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteIssue", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "DeleteIssue" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeleteIssueRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "shortName": "delete_issue" - }, - "description": "Sample for DeleteIssue", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteIssue_sync", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_issue_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_phrase_matcher", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeletePhraseMatcher", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "DeletePhraseMatcher" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeletePhraseMatcherRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "shortName": "delete_phrase_matcher" - }, - "description": "Sample for DeletePhraseMatcher", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeletePhraseMatcher_async", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_phrase_matcher", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeletePhraseMatcher", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "DeletePhraseMatcher" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeletePhraseMatcherRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "shortName": "delete_phrase_matcher" - }, - "description": "Sample for DeletePhraseMatcher", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeletePhraseMatcher_sync", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_phrase_matcher_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.delete_view", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteView", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "DeleteView" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeleteViewRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "shortName": "delete_view" - }, - "description": "Sample for DeleteView", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_view_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteView_async", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_view_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.delete_view", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeleteView", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "DeleteView" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeleteViewRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "shortName": "delete_view" - }, - "description": "Sample for DeleteView", - "file": "contactcenterinsights_v1_generated_contact_center_insights_delete_view_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeleteView_sync", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_delete_view_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.deploy_issue_model", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeployIssueModel", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "DeployIssueModel" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeployIssueModelRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "deploy_issue_model" - }, - "description": "Sample for DeployIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeployIssueModel_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.deploy_issue_model", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.DeployIssueModel", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "DeployIssueModel" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.DeployIssueModelRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "deploy_issue_model" - }, - "description": "Sample for DeployIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_DeployIssueModel_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_deploy_issue_model_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.export_insights_data", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ExportInsightsData", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "ExportInsightsData" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "export_insights_data" - }, - "description": "Sample for ExportInsightsData", - "file": "contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ExportInsightsData_async", - "segments": [ - { - "end": 59, - "start": 27, - "type": "FULL" - }, - { - "end": 59, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 56, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 60, - "start": 57, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.export_insights_data", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ExportInsightsData", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "ExportInsightsData" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ExportInsightsDataRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "export_insights_data" - }, - "description": "Sample for ExportInsightsData", - "file": "contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ExportInsightsData_sync", - "segments": [ - { - "end": 59, - "start": 27, - "type": "FULL" - }, - { - "end": 59, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 56, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 60, - "start": 57, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_export_insights_data_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_analysis", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetAnalysis", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "GetAnalysis" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetAnalysisRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.Analysis", - "shortName": "get_analysis" - }, - "description": "Sample for GetAnalysis", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_analysis_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysis_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_analysis_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_analysis", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetAnalysis", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "GetAnalysis" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetAnalysisRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.Analysis", - "shortName": "get_analysis" - }, - "description": "Sample for GetAnalysis", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_analysis_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetAnalysis_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_analysis_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_conversation", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetConversation", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "GetConversation" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetConversationRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", - "shortName": "get_conversation" - }, - "description": "Sample for GetConversation", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_conversation_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetConversation_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_conversation_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_conversation", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetConversation", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "GetConversation" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetConversationRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", - "shortName": "get_conversation" - }, - "description": "Sample for GetConversation", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_conversation_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetConversation_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_conversation_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_issue_model", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetIssueModel", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "GetIssueModel" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetIssueModelRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.IssueModel", - "shortName": "get_issue_model" - }, - "description": "Sample for GetIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetIssueModel_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_issue_model", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetIssueModel", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "GetIssueModel" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetIssueModelRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.IssueModel", - "shortName": "get_issue_model" - }, - "description": "Sample for GetIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetIssueModel_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_model_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_issue", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetIssue", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "GetIssue" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetIssueRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.Issue", - "shortName": "get_issue" - }, - "description": "Sample for GetIssue", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetIssue_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_issue", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetIssue", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "GetIssue" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetIssueRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.Issue", - "shortName": "get_issue" - }, - "description": "Sample for GetIssue", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetIssue_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_issue_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_phrase_matcher", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetPhraseMatcher", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "GetPhraseMatcher" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetPhraseMatcherRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", - "shortName": "get_phrase_matcher" - }, - "description": "Sample for GetPhraseMatcher", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetPhraseMatcher_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_phrase_matcher", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetPhraseMatcher", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "GetPhraseMatcher" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetPhraseMatcherRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", - "shortName": "get_phrase_matcher" - }, - "description": "Sample for GetPhraseMatcher", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetPhraseMatcher_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_phrase_matcher_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_settings", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetSettings", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "GetSettings" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetSettingsRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.Settings", - "shortName": "get_settings" - }, - "description": "Sample for GetSettings", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_settings_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetSettings_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_settings_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_settings", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetSettings", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "GetSettings" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetSettingsRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.Settings", - "shortName": "get_settings" - }, - "description": "Sample for GetSettings", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_settings_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetSettings_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_settings_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.get_view", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetView", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "GetView" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetViewRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.View", - "shortName": "get_view" - }, - "description": "Sample for GetView", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_view_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetView_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_view_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.get_view", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.GetView", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "GetView" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.GetViewRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.View", - "shortName": "get_view" - }, - "description": "Sample for GetView", - "file": "contactcenterinsights_v1_generated_contact_center_insights_get_view_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_GetView_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_get_view_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.ingest_conversations", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.IngestConversations", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "IngestConversations" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.IngestConversationsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "ingest_conversations" - }, - "description": "Sample for IngestConversations", - "file": "contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_IngestConversations_async", - "segments": [ - { - "end": 63, - "start": 27, - "type": "FULL" - }, - { - "end": 63, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 53, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 60, - "start": 54, - "type": "REQUEST_EXECUTION" - }, - { - "end": 64, - "start": 61, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.ingest_conversations", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.IngestConversations", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "IngestConversations" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.IngestConversationsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "ingest_conversations" - }, - "description": "Sample for IngestConversations", - "file": "contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_IngestConversations_sync", - "segments": [ - { - "end": 63, - "start": 27, - "type": "FULL" - }, - { - "end": 63, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 53, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 60, - "start": 54, - "type": "REQUEST_EXECUTION" - }, - { - "end": 64, - "start": 61, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_ingest_conversations_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_analyses", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListAnalyses", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "ListAnalyses" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListAnalysesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAnalysesAsyncPager", - "shortName": "list_analyses" - }, - "description": "Sample for ListAnalyses", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_analyses_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalyses_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_analyses_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_analyses", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListAnalyses", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "ListAnalyses" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListAnalysesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListAnalysesPager", - "shortName": "list_analyses" - }, - "description": "Sample for ListAnalyses", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_analyses_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListAnalyses_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_analyses_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_conversations", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListConversations", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "ListConversations" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListConversationsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListConversationsAsyncPager", - "shortName": "list_conversations" - }, - "description": "Sample for ListConversations", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_conversations_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListConversations_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_conversations_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_conversations", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListConversations", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "ListConversations" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListConversationsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListConversationsPager", - "shortName": "list_conversations" - }, - "description": "Sample for ListConversations", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_conversations_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListConversations_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_conversations_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_issue_models", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListIssueModels", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "ListIssueModels" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListIssueModelsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.ListIssueModelsResponse", - "shortName": "list_issue_models" - }, - "description": "Sample for ListIssueModels", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListIssueModels_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_issue_models", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListIssueModels", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "ListIssueModels" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListIssueModelsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.ListIssueModelsResponse", - "shortName": "list_issue_models" - }, - "description": "Sample for ListIssueModels", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListIssueModels_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_issue_models_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_issues", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListIssues", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "ListIssues" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListIssuesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.ListIssuesResponse", - "shortName": "list_issues" - }, - "description": "Sample for ListIssues", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_issues_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListIssues_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_issues_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_issues", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListIssues", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "ListIssues" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListIssuesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.ListIssuesResponse", - "shortName": "list_issues" - }, - "description": "Sample for ListIssues", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_issues_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListIssues_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_issues_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_phrase_matchers", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListPhraseMatchers", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "ListPhraseMatchers" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListPhraseMatchersRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListPhraseMatchersAsyncPager", - "shortName": "list_phrase_matchers" - }, - "description": "Sample for ListPhraseMatchers", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListPhraseMatchers_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_phrase_matchers", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListPhraseMatchers", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "ListPhraseMatchers" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListPhraseMatchersRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListPhraseMatchersPager", - "shortName": "list_phrase_matchers" - }, - "description": "Sample for ListPhraseMatchers", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListPhraseMatchers_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_phrase_matchers_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.list_views", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListViews", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "ListViews" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListViewsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListViewsAsyncPager", - "shortName": "list_views" - }, - "description": "Sample for ListViews", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_views_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListViews_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_views_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.list_views", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.ListViews", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "ListViews" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.ListViewsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.services.contact_center_insights.pagers.ListViewsPager", - "shortName": "list_views" - }, - "description": "Sample for ListViews", - "file": "contactcenterinsights_v1_generated_contact_center_insights_list_views_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_ListViews_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_list_views_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.undeploy_issue_model", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UndeployIssueModel", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "UndeployIssueModel" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UndeployIssueModelRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "undeploy_issue_model" - }, - "description": "Sample for UndeployIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UndeployIssueModel_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.undeploy_issue_model", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UndeployIssueModel", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "UndeployIssueModel" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UndeployIssueModelRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "undeploy_issue_model" - }, - "description": "Sample for UndeployIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UndeployIssueModel_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_undeploy_issue_model_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_conversation", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateConversation", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "UpdateConversation" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UpdateConversationRequest" - }, - { - "name": "conversation", - "type": "google.cloud.contact_center_insights_v1.types.Conversation" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", - "shortName": "update_conversation" - }, - "description": "Sample for UpdateConversation", - "file": "contactcenterinsights_v1_generated_contact_center_insights_update_conversation_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateConversation_async", - "segments": [ - { - "end": 50, - "start": 27, - "type": "FULL" - }, - { - "end": 50, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 47, - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 51, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_update_conversation_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_conversation", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateConversation", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "UpdateConversation" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UpdateConversationRequest" - }, - { - "name": "conversation", - "type": "google.cloud.contact_center_insights_v1.types.Conversation" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.Conversation", - "shortName": "update_conversation" - }, - "description": "Sample for UpdateConversation", - "file": "contactcenterinsights_v1_generated_contact_center_insights_update_conversation_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateConversation_sync", - "segments": [ - { - "end": 50, - "start": 27, - "type": "FULL" - }, - { - "end": 50, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 47, - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 51, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_update_conversation_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_issue_model", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateIssueModel", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "UpdateIssueModel" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UpdateIssueModelRequest" - }, - { - "name": "issue_model", - "type": "google.cloud.contact_center_insights_v1.types.IssueModel" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.IssueModel", - "shortName": "update_issue_model" - }, - "description": "Sample for UpdateIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssueModel_async", - "segments": [ - { - "end": 50, - "start": 27, - "type": "FULL" - }, - { - "end": 50, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 47, - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 51, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_issue_model", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateIssueModel", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "UpdateIssueModel" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UpdateIssueModelRequest" - }, - { - "name": "issue_model", - "type": "google.cloud.contact_center_insights_v1.types.IssueModel" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.IssueModel", - "shortName": "update_issue_model" - }, - "description": "Sample for UpdateIssueModel", - "file": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssueModel_sync", - "segments": [ - { - "end": 50, - "start": 27, - "type": "FULL" - }, - { - "end": 50, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 47, - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 51, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_model_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_issue", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateIssue", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "UpdateIssue" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UpdateIssueRequest" - }, - { - "name": "issue", - "type": "google.cloud.contact_center_insights_v1.types.Issue" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.Issue", - "shortName": "update_issue" - }, - "description": "Sample for UpdateIssue", - "file": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssue_async", - "segments": [ - { - "end": 50, - "start": 27, - "type": "FULL" - }, - { - "end": 50, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 47, - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 51, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_issue", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateIssue", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "UpdateIssue" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UpdateIssueRequest" - }, - { - "name": "issue", - "type": "google.cloud.contact_center_insights_v1.types.Issue" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.Issue", - "shortName": "update_issue" - }, - "description": "Sample for UpdateIssue", - "file": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateIssue_sync", - "segments": [ - { - "end": 50, - "start": 27, - "type": "FULL" - }, - { - "end": 50, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 47, - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 51, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_update_issue_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_phrase_matcher", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdatePhraseMatcher", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "UpdatePhraseMatcher" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UpdatePhraseMatcherRequest" - }, - { - "name": "phrase_matcher", - "type": "google.cloud.contact_center_insights_v1.types.PhraseMatcher" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", - "shortName": "update_phrase_matcher" - }, - "description": "Sample for UpdatePhraseMatcher", - "file": "contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdatePhraseMatcher_async", - "segments": [ - { - "end": 54, - "start": 27, - "type": "FULL" - }, - { - "end": 54, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 48, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 51, - "start": 49, - "type": "REQUEST_EXECUTION" - }, - { - "end": 55, - "start": 52, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_phrase_matcher", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdatePhraseMatcher", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "UpdatePhraseMatcher" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UpdatePhraseMatcherRequest" - }, - { - "name": "phrase_matcher", - "type": "google.cloud.contact_center_insights_v1.types.PhraseMatcher" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.PhraseMatcher", - "shortName": "update_phrase_matcher" - }, - "description": "Sample for UpdatePhraseMatcher", - "file": "contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdatePhraseMatcher_sync", - "segments": [ - { - "end": 54, - "start": 27, - "type": "FULL" - }, - { - "end": 54, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 48, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 51, - "start": 49, - "type": "REQUEST_EXECUTION" - }, - { - "end": 55, - "start": 52, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_update_phrase_matcher_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_settings", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateSettings", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "UpdateSettings" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UpdateSettingsRequest" - }, - { - "name": "settings", - "type": "google.cloud.contact_center_insights_v1.types.Settings" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.Settings", - "shortName": "update_settings" - }, - "description": "Sample for UpdateSettings", - "file": "contactcenterinsights_v1_generated_contact_center_insights_update_settings_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateSettings_async", - "segments": [ - { - "end": 50, - "start": 27, - "type": "FULL" - }, - { - "end": 50, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 47, - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 51, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_update_settings_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_settings", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateSettings", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "UpdateSettings" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UpdateSettingsRequest" - }, - { - "name": "settings", - "type": "google.cloud.contact_center_insights_v1.types.Settings" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.Settings", - "shortName": "update_settings" - }, - "description": "Sample for UpdateSettings", - "file": "contactcenterinsights_v1_generated_contact_center_insights_update_settings_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateSettings_sync", - "segments": [ - { - "end": 50, - "start": 27, - "type": "FULL" - }, - { - "end": 50, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 47, - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 51, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_update_settings_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.update_view", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateView", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "UpdateView" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UpdateViewRequest" - }, - { - "name": "view", - "type": "google.cloud.contact_center_insights_v1.types.View" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.View", - "shortName": "update_view" - }, - "description": "Sample for UpdateView", - "file": "contactcenterinsights_v1_generated_contact_center_insights_update_view_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateView_async", - "segments": [ - { - "end": 50, - "start": 27, - "type": "FULL" - }, - { - "end": 50, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 47, - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 51, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_update_view_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.update_view", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UpdateView", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "UpdateView" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UpdateViewRequest" - }, - { - "name": "view", - "type": "google.cloud.contact_center_insights_v1.types.View" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.contact_center_insights_v1.types.View", - "shortName": "update_view" - }, - "description": "Sample for UpdateView", - "file": "contactcenterinsights_v1_generated_contact_center_insights_update_view_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UpdateView_sync", - "segments": [ - { - "end": 50, - "start": 27, - "type": "FULL" - }, - { - "end": 50, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 47, - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 51, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_update_view_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient", - "shortName": "ContactCenterInsightsAsyncClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsAsyncClient.upload_conversation", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UploadConversation", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "UploadConversation" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UploadConversationRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "upload_conversation" - }, - "description": "Sample for UploadConversation", - "file": "contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UploadConversation_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient", - "shortName": "ContactCenterInsightsClient" - }, - "fullName": "google.cloud.contact_center_insights_v1.ContactCenterInsightsClient.upload_conversation", - "method": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights.UploadConversation", - "service": { - "fullName": "google.cloud.contactcenterinsights.v1.ContactCenterInsights", - "shortName": "ContactCenterInsights" - }, - "shortName": "UploadConversation" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.contact_center_insights_v1.types.UploadConversationRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "upload_conversation" - }, - "description": "Sample for UploadConversation", - "file": "contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "contactcenterinsights_v1_generated_ContactCenterInsights_UploadConversation_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "contactcenterinsights_v1_generated_contact_center_insights_upload_conversation_sync.py" - } - ] -} diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/scripts/fixup_contact_center_insights_v1_keywords.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/scripts/fixup_contact_center_insights_v1_keywords.py deleted file mode 100644 index 6c0a0dd4ff19..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/scripts/fixup_contact_center_insights_v1_keywords.py +++ /dev/null @@ -1,213 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2023 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 argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class contact_center_insightsCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'bulk_analyze_conversations': ('parent', 'filter', 'analysis_percentage', 'annotator_selector', ), - 'calculate_issue_model_stats': ('issue_model', ), - 'calculate_stats': ('location', 'filter', ), - 'create_analysis': ('parent', 'analysis', ), - 'create_conversation': ('parent', 'conversation', 'conversation_id', ), - 'create_issue_model': ('parent', 'issue_model', ), - 'create_phrase_matcher': ('parent', 'phrase_matcher', ), - 'create_view': ('parent', 'view', ), - 'delete_analysis': ('name', ), - 'delete_conversation': ('name', 'force', ), - 'delete_issue': ('name', ), - 'delete_issue_model': ('name', ), - 'delete_phrase_matcher': ('name', ), - 'delete_view': ('name', ), - 'deploy_issue_model': ('name', ), - 'export_insights_data': ('parent', 'big_query_destination', 'filter', 'kms_key', 'write_disposition', ), - 'get_analysis': ('name', ), - 'get_conversation': ('name', 'view', ), - 'get_issue': ('name', ), - 'get_issue_model': ('name', ), - 'get_phrase_matcher': ('name', ), - 'get_settings': ('name', ), - 'get_view': ('name', ), - 'ingest_conversations': ('parent', 'gcs_source', 'transcript_object_config', 'conversation_config', ), - 'list_analyses': ('parent', 'page_size', 'page_token', 'filter', ), - 'list_conversations': ('parent', 'page_size', 'page_token', 'filter', 'view', ), - 'list_issue_models': ('parent', ), - 'list_issues': ('parent', ), - 'list_phrase_matchers': ('parent', 'page_size', 'page_token', 'filter', ), - 'list_views': ('parent', 'page_size', 'page_token', ), - 'undeploy_issue_model': ('name', ), - 'update_conversation': ('conversation', 'update_mask', ), - 'update_issue': ('issue', 'update_mask', ), - 'update_issue_model': ('issue_model', 'update_mask', ), - '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', 'speech_config', ), - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: a.keyword.value not in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=contact_center_insightsCallTransformer(), -): - """Duplicate the input dir to the output dir, fixing file method calls. - - Preconditions: - * in_dir is a real directory - * out_dir is a real, empty directory - """ - pyfile_gen = ( - pathlib.Path(os.path.join(root, f)) - for root, _, files in os.walk(in_dir) - for f in files if os.path.splitext(f)[1] == ".py" - ) - - for fpath in pyfile_gen: - with open(fpath, 'r') as f: - src = f.read() - - # Parse the code and insert method call fixes. - tree = cst.parse_module(src) - updated = tree.visit(transformer) - - # Create the path and directory structure for the new file. - updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) - updated_path.parent.mkdir(parents=True, exist_ok=True) - - # Generate the updated source file at the corresponding path. - with open(updated_path, 'w') as f: - f.write(updated.code) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description="""Fix up source that uses the contact_center_insights client library. - -The existing sources are NOT overwritten but are copied to output_dir with changes made. - -Note: This tool operates at a best-effort level at converting positional - parameters in client method calls to keyword based parameters. - Cases where it WILL FAIL include - A) * or ** expansion in a method call. - B) Calls via function or method alias (includes free function calls) - C) Indirect or dispatched calls (e.g. the method is looked up dynamically) - - These all constitute false negatives. The tool will also detect false - positives when an API method shares a name with another method. -""") - parser.add_argument( - '-d', - '--input-directory', - required=True, - dest='input_dir', - help='the input directory to walk for python files to fix up', - ) - parser.add_argument( - '-o', - '--output-directory', - required=True, - dest='output_dir', - help='the directory to output files fixed via un-flattening', - ) - args = parser.parse_args() - input_dir = pathlib.Path(args.input_dir) - output_dir = pathlib.Path(args.output_dir) - if not input_dir.is_dir(): - print( - f"input directory '{input_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if not output_dir.is_dir(): - print( - f"output directory '{output_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if os.listdir(output_dir): - print( - f"output directory '{output_dir}' is not empty", - file=sys.stderr, - ) - sys.exit(-1) - - fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/setup.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/setup.py deleted file mode 100644 index e09f76c7d733..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/setup.py +++ /dev/null @@ -1,90 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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 io -import os - -import setuptools # type: ignore - -package_root = os.path.abspath(os.path.dirname(__file__)) - -name = 'google-cloud-contact-center-insights' - - -description = "Google Cloud Contact Center Insights API client library" - -version = {} -with open(os.path.join(package_root, 'google/cloud/contact_center_insights/gapic_version.py')) as fp: - exec(fp.read(), version) -version = version["__version__"] - -if version[0] == "0": - release_status = "Development Status :: 4 - Beta" -else: - release_status = "Development Status :: 5 - Production/Stable" - -dependencies = [ - "google-api-core[grpc] >= 1.34.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*", - "proto-plus >= 1.22.0, <2.0.0dev", - "proto-plus >= 1.22.2, <2.0.0dev; python_version>='3.11'", - "protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", -] -url = "https://github.com/googleapis/python-contact-center-insights" - -package_root = os.path.abspath(os.path.dirname(__file__)) - -readme_filename = os.path.join(package_root, "README.rst") -with io.open(readme_filename, encoding="utf-8") as readme_file: - readme = readme_file.read() - -packages = [ - package - for package in setuptools.PEP420PackageFinder.find() - if package.startswith("google") -] - -namespaces = ["google", "google.cloud"] - -setuptools.setup( - name=name, - version=version, - description=description, - long_description=readme, - author="Google LLC", - author_email="googleapis-packages@google.com", - license="Apache 2.0", - url=url, - classifiers=[ - release_status, - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Operating System :: OS Independent", - "Topic :: Internet", - ], - platforms="Posix; MacOS X; Windows", - packages=packages, - python_requires=">=3.7", - namespace_packages=namespaces, - install_requires=dependencies, - include_package_data=True, - zip_safe=False, -) diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.10.txt b/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.10.txt deleted file mode 100644 index ed7f9aed2559..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.10.txt +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.11.txt b/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.11.txt deleted file mode 100644 index ed7f9aed2559..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.11.txt +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.12.txt b/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.12.txt deleted file mode 100644 index ed7f9aed2559..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.12.txt +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.7.txt b/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.7.txt deleted file mode 100644 index 6c44adfea7ee..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.7.txt +++ /dev/null @@ -1,9 +0,0 @@ -# This constraints file is used to check that lower bounds -# are correct in setup.py -# List all library dependencies and extras in this file. -# Pin the version to the lower bound. -# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", -# Then this file should have google-cloud-foo==1.14.0 -google-api-core==1.34.0 -proto-plus==1.22.0 -protobuf==3.19.5 diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.8.txt b/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.8.txt deleted file mode 100644 index ed7f9aed2559..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.8.txt +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.9.txt b/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.9.txt deleted file mode 100644 index ed7f9aed2559..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/testing/constraints-3.9.txt +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/__init__.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/__init__.py deleted file mode 100644 index 1b4db446eb8d..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/__init__.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/__init__.py deleted file mode 100644 index 1b4db446eb8d..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/__init__.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/__init__.py deleted file mode 100644 index 1b4db446eb8d..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/contact_center_insights_v1/__init__.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/contact_center_insights_v1/__init__.py deleted file mode 100644 index 1b4db446eb8d..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/contact_center_insights_v1/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2023 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. -# diff --git a/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py b/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py deleted file mode 100644 index 8fa93fe59a94..000000000000 --- a/owl-bot-staging/google-cloud-contact-center-insights/v1/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py +++ /dev/null @@ -1,21043 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2023 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 os -# try/except added for compatibility with python < 3.8 -try: - from unittest import mock - from unittest.mock import AsyncMock # pragma: NO COVER -except ImportError: # pragma: NO COVER - import mock - -import grpc -from grpc.experimental import aio -from collections.abc import Iterable -from google.protobuf import json_format -import json -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule -from proto.marshal.rules import wrappers -from requests import Response -from requests import Request, PreparedRequest -from requests.sessions import Session -from google.protobuf import json_format - -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import future -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import operation -from google.api_core import operation_async # type: ignore -from google.api_core import operations_v1 -from google.api_core import path_template -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.contact_center_insights_v1.services.contact_center_insights import ContactCenterInsightsAsyncClient -from google.cloud.contact_center_insights_v1.services.contact_center_insights import ContactCenterInsightsClient -from google.cloud.contact_center_insights_v1.services.contact_center_insights import pagers -from google.cloud.contact_center_insights_v1.services.contact_center_insights import transports -from google.cloud.contact_center_insights_v1.types import contact_center_insights -from google.cloud.contact_center_insights_v1.types import resources -from google.longrunning import operations_pb2 # type: ignore -from google.oauth2 import service_account -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -import google.auth - - -def client_cert_source_callback(): - return b"cert bytes", b"key bytes" - - -# If default endpoint is localhost, then default mtls endpoint will be the same. -# This method modifies the default endpoint so the client can produce a different -# mtls endpoint for endpoint testing purposes. -def modify_default_endpoint(client): - return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT - - -def test__get_default_mtls_endpoint(): - api_endpoint = "example.googleapis.com" - api_mtls_endpoint = "example.mtls.googleapis.com" - sandbox_endpoint = "example.sandbox.googleapis.com" - sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" - non_googleapi = "api.example.com" - - assert ContactCenterInsightsClient._get_default_mtls_endpoint(None) is None - assert ContactCenterInsightsClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert ContactCenterInsightsClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert ContactCenterInsightsClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert ContactCenterInsightsClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert ContactCenterInsightsClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class,transport_name", [ - (ContactCenterInsightsClient, "grpc"), - (ContactCenterInsightsAsyncClient, "grpc_asyncio"), - (ContactCenterInsightsClient, "rest"), -]) -def test_contact_center_insights_client_from_service_account_info(client_class, transport_name): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: - factory.return_value = creds - info = {"valid": True} - client = client_class.from_service_account_info(info, transport=transport_name) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == ( - 'contactcenterinsights.googleapis.com:443' - if transport_name in ['grpc', 'grpc_asyncio'] - else - 'https://contactcenterinsights.googleapis.com' - ) - - -@pytest.mark.parametrize("transport_class,transport_name", [ - (transports.ContactCenterInsightsGrpcTransport, "grpc"), - (transports.ContactCenterInsightsGrpcAsyncIOTransport, "grpc_asyncio"), - (transports.ContactCenterInsightsRestTransport, "rest"), -]) -def test_contact_center_insights_client_service_account_always_use_jwt(transport_class, transport_name): - with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: - creds = service_account.Credentials(None, None, None) - transport = transport_class(credentials=creds, always_use_jwt_access=True) - use_jwt.assert_called_once_with(True) - - with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: - creds = service_account.Credentials(None, None, None) - transport = transport_class(credentials=creds, always_use_jwt_access=False) - use_jwt.assert_not_called() - - -@pytest.mark.parametrize("client_class,transport_name", [ - (ContactCenterInsightsClient, "grpc"), - (ContactCenterInsightsAsyncClient, "grpc_asyncio"), - (ContactCenterInsightsClient, "rest"), -]) -def test_contact_center_insights_client_from_service_account_file(client_class, transport_name): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory: - factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json", transport=transport_name) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - client = client_class.from_service_account_json("dummy/file/path.json", transport=transport_name) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == ( - 'contactcenterinsights.googleapis.com:443' - if transport_name in ['grpc', 'grpc_asyncio'] - else - 'https://contactcenterinsights.googleapis.com' - ) - - -def test_contact_center_insights_client_get_transport_class(): - transport = ContactCenterInsightsClient.get_transport_class() - available_transports = [ - transports.ContactCenterInsightsGrpcTransport, - transports.ContactCenterInsightsRestTransport, - ] - assert transport in available_transports - - transport = ContactCenterInsightsClient.get_transport_class("grpc") - assert transport == transports.ContactCenterInsightsGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (ContactCenterInsightsClient, transports.ContactCenterInsightsGrpcTransport, "grpc"), - (ContactCenterInsightsAsyncClient, transports.ContactCenterInsightsGrpcAsyncIOTransport, "grpc_asyncio"), - (ContactCenterInsightsClient, transports.ContactCenterInsightsRestTransport, "rest"), -]) -@mock.patch.object(ContactCenterInsightsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ContactCenterInsightsClient)) -@mock.patch.object(ContactCenterInsightsAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ContactCenterInsightsAsyncClient)) -def test_contact_center_insights_client_client_options(client_class, transport_class, transport_name): - # Check that if channel is provided we won't create a new one. - with mock.patch.object(ContactCenterInsightsClient, 'get_transport_class') as gtc: - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ) - client = client_class(transport=transport) - gtc.assert_not_called() - - # Check that if channel is provided via str we will create a new one. - with mock.patch.object(ContactCenterInsightsClient, 'get_transport_class') as gtc: - client = client_class(transport=transport_name) - gtc.assert_called() - - # Check the case api_endpoint is provided. - options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(transport=transport_name, client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_MTLS_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has - # unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError): - client = client_class(transport=transport_name) - - # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): - with pytest.raises(ValueError): - client = client_class(transport=transport_name) - - # Check the case quota_project_id is provided - options = client_options.ClientOptions(quota_project_id="octopus") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id="octopus", - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - # Check the case api_endpoint is provided - options = client_options.ClientOptions(api_audience="https://language.googleapis.com") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience="https://language.googleapis.com" - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (ContactCenterInsightsClient, transports.ContactCenterInsightsGrpcTransport, "grpc", "true"), - (ContactCenterInsightsAsyncClient, transports.ContactCenterInsightsGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (ContactCenterInsightsClient, transports.ContactCenterInsightsGrpcTransport, "grpc", "false"), - (ContactCenterInsightsAsyncClient, transports.ContactCenterInsightsGrpcAsyncIOTransport, "grpc_asyncio", "false"), - (ContactCenterInsightsClient, transports.ContactCenterInsightsRestTransport, "rest", "true"), - (ContactCenterInsightsClient, transports.ContactCenterInsightsRestTransport, "rest", "false"), -]) -@mock.patch.object(ContactCenterInsightsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ContactCenterInsightsClient)) -@mock.patch.object(ContactCenterInsightsAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ContactCenterInsightsAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_contact_center_insights_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): - # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default - # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. - - # Check the case client_cert_source is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - - if use_client_cert_env == "false": - expected_client_cert_source = None - expected_host = client.DEFAULT_ENDPOINT - else: - expected_client_cert_source = client_cert_source_callback - expected_host = client.DEFAULT_MTLS_ENDPOINT - - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case ADC client cert is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): - if use_client_cert_env == "false": - expected_host = client.DEFAULT_ENDPOINT - expected_client_cert_source = None - else: - expected_host = client.DEFAULT_MTLS_ENDPOINT - expected_client_cert_source = client_cert_source_callback - - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case client_cert_source and ADC client cert are not provided. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class", [ - ContactCenterInsightsClient, ContactCenterInsightsAsyncClient -]) -@mock.patch.object(ContactCenterInsightsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ContactCenterInsightsClient)) -@mock.patch.object(ContactCenterInsightsAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ContactCenterInsightsAsyncClient)) -def test_contact_center_insights_client_get_mtls_endpoint_and_cert_source(client_class): - mock_client_cert_source = mock.Mock() - - # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - mock_api_endpoint = "foo" - options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint) - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(options) - assert api_endpoint == mock_api_endpoint - assert cert_source == mock_client_cert_source - - # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): - mock_client_cert_source = mock.Mock() - mock_api_endpoint = "foo" - options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint) - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(options) - assert api_endpoint == mock_api_endpoint - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=False): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=mock_client_cert_source): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT - assert cert_source == mock_client_cert_source - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (ContactCenterInsightsClient, transports.ContactCenterInsightsGrpcTransport, "grpc"), - (ContactCenterInsightsAsyncClient, transports.ContactCenterInsightsGrpcAsyncIOTransport, "grpc_asyncio"), - (ContactCenterInsightsClient, transports.ContactCenterInsightsRestTransport, "rest"), -]) -def test_contact_center_insights_client_client_options_scopes(client_class, transport_class, transport_name): - # Check the case scopes are provided. - options = client_options.ClientOptions( - scopes=["1", "2"], - ) - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=["1", "2"], - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (ContactCenterInsightsClient, transports.ContactCenterInsightsGrpcTransport, "grpc", grpc_helpers), - (ContactCenterInsightsAsyncClient, transports.ContactCenterInsightsGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), - (ContactCenterInsightsClient, transports.ContactCenterInsightsRestTransport, "rest", None), -]) -def test_contact_center_insights_client_client_options_credentials_file(client_class, transport_class, transport_name, grpc_helpers): - # Check the case credentials file is provided. - options = client_options.ClientOptions( - credentials_file="credentials.json" - ) - - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - -def test_contact_center_insights_client_client_options_from_dict(): - with mock.patch('google.cloud.contact_center_insights_v1.services.contact_center_insights.transports.ContactCenterInsightsGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = ContactCenterInsightsClient( - client_options={'api_endpoint': 'squid.clam.whelk'} - ) - grpc_transport.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (ContactCenterInsightsClient, transports.ContactCenterInsightsGrpcTransport, "grpc", grpc_helpers), - (ContactCenterInsightsAsyncClient, transports.ContactCenterInsightsGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_contact_center_insights_client_create_channel_credentials_file(client_class, transport_class, transport_name, grpc_helpers): - # Check the case credentials file is provided. - options = client_options.ClientOptions( - credentials_file="credentials.json" - ) - - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # test that the credentials from file are saved and used as the credentials. - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch.object( - google.auth, "default", autospec=True - ) as adc, mock.patch.object( - grpc_helpers, "create_channel" - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - file_creds = ga_credentials.AnonymousCredentials() - load_creds.return_value = (file_creds, None) - adc.return_value = (creds, None) - client = client_class(client_options=options, transport=transport_name) - create_channel.assert_called_with( - "contactcenterinsights.googleapis.com:443", - credentials=file_creds, - credentials_file=None, - quota_project_id=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - scopes=None, - default_host="contactcenterinsights.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.CreateConversationRequest, - dict, -]) -def test_create_conversation(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_conversation), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Conversation( - name='name_value', - language_code='language_code_value', - agent_id='agent_id_value', - medium=resources.Conversation.Medium.PHONE_CALL, - turn_count=1105, - obfuscated_user_id='obfuscated_user_id_value', - ) - response = client.create_conversation(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CreateConversationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Conversation) - assert response.name == 'name_value' - assert response.language_code == 'language_code_value' - assert response.agent_id == 'agent_id_value' - assert response.medium == resources.Conversation.Medium.PHONE_CALL - assert response.turn_count == 1105 - assert response.obfuscated_user_id == 'obfuscated_user_id_value' - - -def test_create_conversation_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_conversation), - '__call__') as call: - client.create_conversation() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CreateConversationRequest() - -@pytest.mark.asyncio -async def test_create_conversation_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.CreateConversationRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_conversation), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation( - name='name_value', - language_code='language_code_value', - agent_id='agent_id_value', - medium=resources.Conversation.Medium.PHONE_CALL, - turn_count=1105, - obfuscated_user_id='obfuscated_user_id_value', - )) - response = await client.create_conversation(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CreateConversationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Conversation) - assert response.name == 'name_value' - assert response.language_code == 'language_code_value' - assert response.agent_id == 'agent_id_value' - assert response.medium == resources.Conversation.Medium.PHONE_CALL - assert response.turn_count == 1105 - assert response.obfuscated_user_id == 'obfuscated_user_id_value' - - -@pytest.mark.asyncio -async def test_create_conversation_async_from_dict(): - await test_create_conversation_async(request_type=dict) - - -def test_create_conversation_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.CreateConversationRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_conversation), - '__call__') as call: - call.return_value = resources.Conversation() - client.create_conversation(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_create_conversation_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.CreateConversationRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_conversation), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation()) - await client.create_conversation(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_create_conversation_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_conversation), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Conversation() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_conversation( - parent='parent_value', - conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), - conversation_id='conversation_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].conversation - mock_val = resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)) - assert arg == mock_val - arg = args[0].conversation_id - mock_val = 'conversation_id_value' - assert arg == mock_val - - -def test_create_conversation_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_conversation( - contact_center_insights.CreateConversationRequest(), - parent='parent_value', - conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), - conversation_id='conversation_id_value', - ) - -@pytest.mark.asyncio -async def test_create_conversation_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_conversation), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Conversation() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_conversation( - parent='parent_value', - conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), - conversation_id='conversation_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].conversation - mock_val = resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)) - assert arg == mock_val - arg = args[0].conversation_id - mock_val = 'conversation_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_conversation_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_conversation( - contact_center_insights.CreateConversationRequest(), - parent='parent_value', - conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), - conversation_id='conversation_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.UploadConversationRequest, - dict, -]) -def test_upload_conversation(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.upload_conversation), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.upload_conversation(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UploadConversationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_upload_conversation_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.upload_conversation), - '__call__') as call: - client.upload_conversation() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UploadConversationRequest() - -@pytest.mark.asyncio -async def test_upload_conversation_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UploadConversationRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.upload_conversation), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.upload_conversation(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UploadConversationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_upload_conversation_async_from_dict(): - await test_upload_conversation_async(request_type=dict) - - -def test_upload_conversation_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.UploadConversationRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.upload_conversation), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.upload_conversation(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_upload_conversation_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.UploadConversationRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.upload_conversation), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.upload_conversation(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.UpdateConversationRequest, - dict, -]) -def test_update_conversation(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_conversation), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Conversation( - name='name_value', - language_code='language_code_value', - agent_id='agent_id_value', - medium=resources.Conversation.Medium.PHONE_CALL, - turn_count=1105, - obfuscated_user_id='obfuscated_user_id_value', - ) - response = client.update_conversation(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UpdateConversationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Conversation) - assert response.name == 'name_value' - assert response.language_code == 'language_code_value' - assert response.agent_id == 'agent_id_value' - assert response.medium == resources.Conversation.Medium.PHONE_CALL - assert response.turn_count == 1105 - assert response.obfuscated_user_id == 'obfuscated_user_id_value' - - -def test_update_conversation_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_conversation), - '__call__') as call: - client.update_conversation() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UpdateConversationRequest() - -@pytest.mark.asyncio -async def test_update_conversation_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UpdateConversationRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_conversation), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation( - name='name_value', - language_code='language_code_value', - agent_id='agent_id_value', - medium=resources.Conversation.Medium.PHONE_CALL, - turn_count=1105, - obfuscated_user_id='obfuscated_user_id_value', - )) - response = await client.update_conversation(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UpdateConversationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Conversation) - assert response.name == 'name_value' - assert response.language_code == 'language_code_value' - assert response.agent_id == 'agent_id_value' - assert response.medium == resources.Conversation.Medium.PHONE_CALL - assert response.turn_count == 1105 - assert response.obfuscated_user_id == 'obfuscated_user_id_value' - - -@pytest.mark.asyncio -async def test_update_conversation_async_from_dict(): - await test_update_conversation_async(request_type=dict) - - -def test_update_conversation_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.UpdateConversationRequest() - - request.conversation.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_conversation), - '__call__') as call: - call.return_value = resources.Conversation() - client.update_conversation(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'conversation.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_conversation_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.UpdateConversationRequest() - - request.conversation.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_conversation), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation()) - await client.update_conversation(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'conversation.name=name_value', - ) in kw['metadata'] - - -def test_update_conversation_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_conversation), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Conversation() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_conversation( - conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].conversation - mock_val = resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)) - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - - -def test_update_conversation_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_conversation( - contact_center_insights.UpdateConversationRequest(), - conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_conversation_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_conversation), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Conversation() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_conversation( - conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].conversation - mock_val = resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)) - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - -@pytest.mark.asyncio -async def test_update_conversation_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_conversation( - contact_center_insights.UpdateConversationRequest(), - conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.GetConversationRequest, - dict, -]) -def test_get_conversation(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_conversation), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Conversation( - name='name_value', - language_code='language_code_value', - agent_id='agent_id_value', - medium=resources.Conversation.Medium.PHONE_CALL, - turn_count=1105, - obfuscated_user_id='obfuscated_user_id_value', - ) - response = client.get_conversation(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetConversationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Conversation) - assert response.name == 'name_value' - assert response.language_code == 'language_code_value' - assert response.agent_id == 'agent_id_value' - assert response.medium == resources.Conversation.Medium.PHONE_CALL - assert response.turn_count == 1105 - assert response.obfuscated_user_id == 'obfuscated_user_id_value' - - -def test_get_conversation_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_conversation), - '__call__') as call: - client.get_conversation() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetConversationRequest() - -@pytest.mark.asyncio -async def test_get_conversation_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.GetConversationRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_conversation), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation( - name='name_value', - language_code='language_code_value', - agent_id='agent_id_value', - medium=resources.Conversation.Medium.PHONE_CALL, - turn_count=1105, - obfuscated_user_id='obfuscated_user_id_value', - )) - response = await client.get_conversation(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetConversationRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Conversation) - assert response.name == 'name_value' - assert response.language_code == 'language_code_value' - assert response.agent_id == 'agent_id_value' - assert response.medium == resources.Conversation.Medium.PHONE_CALL - assert response.turn_count == 1105 - assert response.obfuscated_user_id == 'obfuscated_user_id_value' - - -@pytest.mark.asyncio -async def test_get_conversation_async_from_dict(): - await test_get_conversation_async(request_type=dict) - - -def test_get_conversation_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.GetConversationRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_conversation), - '__call__') as call: - call.return_value = resources.Conversation() - client.get_conversation(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_conversation_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.GetConversationRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_conversation), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation()) - await client.get_conversation(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_get_conversation_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_conversation), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Conversation() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_conversation( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_conversation_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_conversation( - contact_center_insights.GetConversationRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_conversation_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_conversation), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Conversation() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Conversation()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_conversation( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_conversation_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_conversation( - contact_center_insights.GetConversationRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.ListConversationsRequest, - dict, -]) -def test_list_conversations(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_conversations), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListConversationsResponse( - next_page_token='next_page_token_value', - ) - response = client.list_conversations(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListConversationsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListConversationsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_conversations_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_conversations), - '__call__') as call: - client.list_conversations() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListConversationsRequest() - -@pytest.mark.asyncio -async def test_list_conversations_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.ListConversationsRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_conversations), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListConversationsResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_conversations(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListConversationsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListConversationsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_conversations_async_from_dict(): - await test_list_conversations_async(request_type=dict) - - -def test_list_conversations_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.ListConversationsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_conversations), - '__call__') as call: - call.return_value = contact_center_insights.ListConversationsResponse() - client.list_conversations(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_list_conversations_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.ListConversationsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_conversations), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListConversationsResponse()) - await client.list_conversations(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_list_conversations_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_conversations), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListConversationsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_conversations( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_list_conversations_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_conversations( - contact_center_insights.ListConversationsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_conversations_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_conversations), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListConversationsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListConversationsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_conversations( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_conversations_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_conversations( - contact_center_insights.ListConversationsRequest(), - parent='parent_value', - ) - - -def test_list_conversations_pager(transport_name: str = "grpc"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_conversations), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - contact_center_insights.ListConversationsResponse( - conversations=[ - resources.Conversation(), - resources.Conversation(), - resources.Conversation(), - ], - next_page_token='abc', - ), - contact_center_insights.ListConversationsResponse( - conversations=[], - next_page_token='def', - ), - contact_center_insights.ListConversationsResponse( - conversations=[ - resources.Conversation(), - ], - next_page_token='ghi', - ), - contact_center_insights.ListConversationsResponse( - conversations=[ - resources.Conversation(), - resources.Conversation(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_conversations(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.Conversation) - for i in results) -def test_list_conversations_pages(transport_name: str = "grpc"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_conversations), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - contact_center_insights.ListConversationsResponse( - conversations=[ - resources.Conversation(), - resources.Conversation(), - resources.Conversation(), - ], - next_page_token='abc', - ), - contact_center_insights.ListConversationsResponse( - conversations=[], - next_page_token='def', - ), - contact_center_insights.ListConversationsResponse( - conversations=[ - resources.Conversation(), - ], - next_page_token='ghi', - ), - contact_center_insights.ListConversationsResponse( - conversations=[ - resources.Conversation(), - resources.Conversation(), - ], - ), - RuntimeError, - ) - pages = list(client.list_conversations(request={}).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.asyncio -async def test_list_conversations_async_pager(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_conversations), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - contact_center_insights.ListConversationsResponse( - conversations=[ - resources.Conversation(), - resources.Conversation(), - resources.Conversation(), - ], - next_page_token='abc', - ), - contact_center_insights.ListConversationsResponse( - conversations=[], - next_page_token='def', - ), - contact_center_insights.ListConversationsResponse( - conversations=[ - resources.Conversation(), - ], - next_page_token='ghi', - ), - contact_center_insights.ListConversationsResponse( - conversations=[ - resources.Conversation(), - resources.Conversation(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_conversations(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, resources.Conversation) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_conversations_async_pages(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_conversations), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - contact_center_insights.ListConversationsResponse( - conversations=[ - resources.Conversation(), - resources.Conversation(), - resources.Conversation(), - ], - next_page_token='abc', - ), - contact_center_insights.ListConversationsResponse( - conversations=[], - next_page_token='def', - ), - contact_center_insights.ListConversationsResponse( - conversations=[ - resources.Conversation(), - ], - next_page_token='ghi', - ), - contact_center_insights.ListConversationsResponse( - conversations=[ - resources.Conversation(), - resources.Conversation(), - ], - ), - RuntimeError, - ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_conversations(request={}) - ).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.DeleteConversationRequest, - dict, -]) -def test_delete_conversation(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_conversation), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_conversation(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeleteConversationRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_conversation_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_conversation), - '__call__') as call: - client.delete_conversation() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeleteConversationRequest() - -@pytest.mark.asyncio -async def test_delete_conversation_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.DeleteConversationRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_conversation), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_conversation(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeleteConversationRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_conversation_async_from_dict(): - await test_delete_conversation_async(request_type=dict) - - -def test_delete_conversation_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.DeleteConversationRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_conversation), - '__call__') as call: - call.return_value = None - client.delete_conversation(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_delete_conversation_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.DeleteConversationRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_conversation), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_conversation(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_delete_conversation_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_conversation), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_conversation( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_delete_conversation_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_conversation( - contact_center_insights.DeleteConversationRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_conversation_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_conversation), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_conversation( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_delete_conversation_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_conversation( - contact_center_insights.DeleteConversationRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.CreateAnalysisRequest, - dict, -]) -def test_create_analysis(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_analysis), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_analysis(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CreateAnalysisRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_analysis_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_analysis), - '__call__') as call: - client.create_analysis() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CreateAnalysisRequest() - -@pytest.mark.asyncio -async def test_create_analysis_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.CreateAnalysisRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_analysis), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.create_analysis(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CreateAnalysisRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_analysis_async_from_dict(): - await test_create_analysis_async(request_type=dict) - - -def test_create_analysis_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.CreateAnalysisRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_analysis), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_analysis(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_create_analysis_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.CreateAnalysisRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_analysis), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_analysis(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_create_analysis_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_analysis), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_analysis( - parent='parent_value', - analysis=resources.Analysis(name='name_value'), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].analysis - mock_val = resources.Analysis(name='name_value') - assert arg == mock_val - - -def test_create_analysis_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_analysis( - contact_center_insights.CreateAnalysisRequest(), - parent='parent_value', - analysis=resources.Analysis(name='name_value'), - ) - -@pytest.mark.asyncio -async def test_create_analysis_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_analysis), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_analysis( - parent='parent_value', - analysis=resources.Analysis(name='name_value'), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].analysis - mock_val = resources.Analysis(name='name_value') - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_analysis_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_analysis( - contact_center_insights.CreateAnalysisRequest(), - parent='parent_value', - analysis=resources.Analysis(name='name_value'), - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.GetAnalysisRequest, - dict, -]) -def test_get_analysis(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_analysis), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Analysis( - name='name_value', - ) - response = client.get_analysis(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetAnalysisRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Analysis) - assert response.name == 'name_value' - - -def test_get_analysis_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_analysis), - '__call__') as call: - client.get_analysis() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetAnalysisRequest() - -@pytest.mark.asyncio -async def test_get_analysis_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.GetAnalysisRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_analysis), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Analysis( - name='name_value', - )) - response = await client.get_analysis(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetAnalysisRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Analysis) - assert response.name == 'name_value' - - -@pytest.mark.asyncio -async def test_get_analysis_async_from_dict(): - await test_get_analysis_async(request_type=dict) - - -def test_get_analysis_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.GetAnalysisRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_analysis), - '__call__') as call: - call.return_value = resources.Analysis() - client.get_analysis(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_analysis_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.GetAnalysisRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_analysis), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Analysis()) - await client.get_analysis(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_get_analysis_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_analysis), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Analysis() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_analysis( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_analysis_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_analysis( - contact_center_insights.GetAnalysisRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_analysis_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_analysis), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Analysis() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Analysis()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_analysis( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_analysis_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_analysis( - contact_center_insights.GetAnalysisRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.ListAnalysesRequest, - dict, -]) -def test_list_analyses(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_analyses), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListAnalysesResponse( - next_page_token='next_page_token_value', - ) - response = client.list_analyses(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListAnalysesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListAnalysesPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_analyses_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_analyses), - '__call__') as call: - client.list_analyses() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListAnalysesRequest() - -@pytest.mark.asyncio -async def test_list_analyses_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.ListAnalysesRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_analyses), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListAnalysesResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_analyses(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListAnalysesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListAnalysesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_analyses_async_from_dict(): - await test_list_analyses_async(request_type=dict) - - -def test_list_analyses_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.ListAnalysesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_analyses), - '__call__') as call: - call.return_value = contact_center_insights.ListAnalysesResponse() - client.list_analyses(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_list_analyses_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.ListAnalysesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_analyses), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListAnalysesResponse()) - await client.list_analyses(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_list_analyses_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_analyses), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListAnalysesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_analyses( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_list_analyses_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_analyses( - contact_center_insights.ListAnalysesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_analyses_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_analyses), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListAnalysesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListAnalysesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_analyses( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_analyses_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_analyses( - contact_center_insights.ListAnalysesRequest(), - parent='parent_value', - ) - - -def test_list_analyses_pager(transport_name: str = "grpc"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_analyses), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - contact_center_insights.ListAnalysesResponse( - analyses=[ - resources.Analysis(), - resources.Analysis(), - resources.Analysis(), - ], - next_page_token='abc', - ), - contact_center_insights.ListAnalysesResponse( - analyses=[], - next_page_token='def', - ), - contact_center_insights.ListAnalysesResponse( - analyses=[ - resources.Analysis(), - ], - next_page_token='ghi', - ), - contact_center_insights.ListAnalysesResponse( - analyses=[ - resources.Analysis(), - resources.Analysis(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_analyses(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.Analysis) - for i in results) -def test_list_analyses_pages(transport_name: str = "grpc"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_analyses), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - contact_center_insights.ListAnalysesResponse( - analyses=[ - resources.Analysis(), - resources.Analysis(), - resources.Analysis(), - ], - next_page_token='abc', - ), - contact_center_insights.ListAnalysesResponse( - analyses=[], - next_page_token='def', - ), - contact_center_insights.ListAnalysesResponse( - analyses=[ - resources.Analysis(), - ], - next_page_token='ghi', - ), - contact_center_insights.ListAnalysesResponse( - analyses=[ - resources.Analysis(), - resources.Analysis(), - ], - ), - RuntimeError, - ) - pages = list(client.list_analyses(request={}).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.asyncio -async def test_list_analyses_async_pager(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_analyses), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - contact_center_insights.ListAnalysesResponse( - analyses=[ - resources.Analysis(), - resources.Analysis(), - resources.Analysis(), - ], - next_page_token='abc', - ), - contact_center_insights.ListAnalysesResponse( - analyses=[], - next_page_token='def', - ), - contact_center_insights.ListAnalysesResponse( - analyses=[ - resources.Analysis(), - ], - next_page_token='ghi', - ), - contact_center_insights.ListAnalysesResponse( - analyses=[ - resources.Analysis(), - resources.Analysis(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_analyses(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, resources.Analysis) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_analyses_async_pages(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_analyses), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - contact_center_insights.ListAnalysesResponse( - analyses=[ - resources.Analysis(), - resources.Analysis(), - resources.Analysis(), - ], - next_page_token='abc', - ), - contact_center_insights.ListAnalysesResponse( - analyses=[], - next_page_token='def', - ), - contact_center_insights.ListAnalysesResponse( - analyses=[ - resources.Analysis(), - ], - next_page_token='ghi', - ), - contact_center_insights.ListAnalysesResponse( - analyses=[ - resources.Analysis(), - resources.Analysis(), - ], - ), - RuntimeError, - ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_analyses(request={}) - ).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.DeleteAnalysisRequest, - dict, -]) -def test_delete_analysis(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_analysis), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_analysis(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeleteAnalysisRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_analysis_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_analysis), - '__call__') as call: - client.delete_analysis() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeleteAnalysisRequest() - -@pytest.mark.asyncio -async def test_delete_analysis_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.DeleteAnalysisRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_analysis), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_analysis(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeleteAnalysisRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_analysis_async_from_dict(): - await test_delete_analysis_async(request_type=dict) - - -def test_delete_analysis_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.DeleteAnalysisRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_analysis), - '__call__') as call: - call.return_value = None - client.delete_analysis(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_delete_analysis_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.DeleteAnalysisRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_analysis), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_analysis(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_delete_analysis_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_analysis), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_analysis( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_delete_analysis_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_analysis( - contact_center_insights.DeleteAnalysisRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_analysis_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_analysis), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_analysis( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_delete_analysis_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_analysis( - contact_center_insights.DeleteAnalysisRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.BulkAnalyzeConversationsRequest, - dict, -]) -def test_bulk_analyze_conversations(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.bulk_analyze_conversations), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.bulk_analyze_conversations(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.BulkAnalyzeConversationsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_bulk_analyze_conversations_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.bulk_analyze_conversations), - '__call__') as call: - client.bulk_analyze_conversations() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.BulkAnalyzeConversationsRequest() - -@pytest.mark.asyncio -async def test_bulk_analyze_conversations_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.BulkAnalyzeConversationsRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.bulk_analyze_conversations), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.bulk_analyze_conversations(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.BulkAnalyzeConversationsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_bulk_analyze_conversations_async_from_dict(): - await test_bulk_analyze_conversations_async(request_type=dict) - - -def test_bulk_analyze_conversations_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.BulkAnalyzeConversationsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.bulk_analyze_conversations), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.bulk_analyze_conversations(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_bulk_analyze_conversations_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.BulkAnalyzeConversationsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.bulk_analyze_conversations), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.bulk_analyze_conversations(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_bulk_analyze_conversations_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.bulk_analyze_conversations), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.bulk_analyze_conversations( - parent='parent_value', - filter='filter_value', - analysis_percentage=0.20170000000000002, - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].filter - mock_val = 'filter_value' - assert arg == mock_val - assert math.isclose(args[0].analysis_percentage, 0.20170000000000002, rel_tol=1e-6) - - -def test_bulk_analyze_conversations_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.bulk_analyze_conversations( - contact_center_insights.BulkAnalyzeConversationsRequest(), - parent='parent_value', - filter='filter_value', - analysis_percentage=0.20170000000000002, - ) - -@pytest.mark.asyncio -async def test_bulk_analyze_conversations_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.bulk_analyze_conversations), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.bulk_analyze_conversations( - parent='parent_value', - filter='filter_value', - analysis_percentage=0.20170000000000002, - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].filter - mock_val = 'filter_value' - assert arg == mock_val - assert math.isclose(args[0].analysis_percentage, 0.20170000000000002, rel_tol=1e-6) - -@pytest.mark.asyncio -async def test_bulk_analyze_conversations_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.bulk_analyze_conversations( - contact_center_insights.BulkAnalyzeConversationsRequest(), - parent='parent_value', - filter='filter_value', - analysis_percentage=0.20170000000000002, - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.IngestConversationsRequest, - dict, -]) -def test_ingest_conversations(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.ingest_conversations), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.ingest_conversations(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.IngestConversationsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_ingest_conversations_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.ingest_conversations), - '__call__') as call: - client.ingest_conversations() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.IngestConversationsRequest() - -@pytest.mark.asyncio -async def test_ingest_conversations_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.IngestConversationsRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.ingest_conversations), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.ingest_conversations(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.IngestConversationsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_ingest_conversations_async_from_dict(): - await test_ingest_conversations_async(request_type=dict) - - -def test_ingest_conversations_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.IngestConversationsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.ingest_conversations), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.ingest_conversations(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_ingest_conversations_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.IngestConversationsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.ingest_conversations), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.ingest_conversations(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_ingest_conversations_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.ingest_conversations), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.ingest_conversations( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_ingest_conversations_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.ingest_conversations( - contact_center_insights.IngestConversationsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_ingest_conversations_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.ingest_conversations), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.ingest_conversations( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_ingest_conversations_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.ingest_conversations( - contact_center_insights.IngestConversationsRequest(), - parent='parent_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.ExportInsightsDataRequest, - dict, -]) -def test_export_insights_data(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.export_insights_data), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.export_insights_data(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ExportInsightsDataRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_export_insights_data_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.export_insights_data), - '__call__') as call: - client.export_insights_data() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ExportInsightsDataRequest() - -@pytest.mark.asyncio -async def test_export_insights_data_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.ExportInsightsDataRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.export_insights_data), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.export_insights_data(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ExportInsightsDataRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_export_insights_data_async_from_dict(): - await test_export_insights_data_async(request_type=dict) - - -def test_export_insights_data_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.ExportInsightsDataRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.export_insights_data), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.export_insights_data(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_export_insights_data_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.ExportInsightsDataRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.export_insights_data), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.export_insights_data(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_export_insights_data_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.export_insights_data), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.export_insights_data( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_export_insights_data_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.export_insights_data( - contact_center_insights.ExportInsightsDataRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_export_insights_data_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.export_insights_data), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.export_insights_data( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_export_insights_data_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.export_insights_data( - contact_center_insights.ExportInsightsDataRequest(), - parent='parent_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.CreateIssueModelRequest, - dict, -]) -def test_create_issue_model(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CreateIssueModelRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_issue_model_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_issue_model), - '__call__') as call: - client.create_issue_model() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CreateIssueModelRequest() - -@pytest.mark.asyncio -async def test_create_issue_model_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.CreateIssueModelRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.create_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CreateIssueModelRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_issue_model_async_from_dict(): - await test_create_issue_model_async(request_type=dict) - - -def test_create_issue_model_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.CreateIssueModelRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_issue_model), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_create_issue_model_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.CreateIssueModelRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_issue_model), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_create_issue_model_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_issue_model( - parent='parent_value', - issue_model=resources.IssueModel(name='name_value'), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].issue_model - mock_val = resources.IssueModel(name='name_value') - assert arg == mock_val - - -def test_create_issue_model_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_issue_model( - contact_center_insights.CreateIssueModelRequest(), - parent='parent_value', - issue_model=resources.IssueModel(name='name_value'), - ) - -@pytest.mark.asyncio -async def test_create_issue_model_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_issue_model( - parent='parent_value', - issue_model=resources.IssueModel(name='name_value'), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].issue_model - mock_val = resources.IssueModel(name='name_value') - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_issue_model_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_issue_model( - contact_center_insights.CreateIssueModelRequest(), - parent='parent_value', - issue_model=resources.IssueModel(name='name_value'), - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.UpdateIssueModelRequest, - dict, -]) -def test_update_issue_model(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.IssueModel( - name='name_value', - display_name='display_name_value', - issue_count=1201, - state=resources.IssueModel.State.UNDEPLOYED, - model_type=resources.IssueModel.ModelType.TYPE_V1, - language_code='language_code_value', - ) - response = client.update_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UpdateIssueModelRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.IssueModel) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.issue_count == 1201 - assert response.state == resources.IssueModel.State.UNDEPLOYED - assert response.model_type == resources.IssueModel.ModelType.TYPE_V1 - assert response.language_code == 'language_code_value' - - -def test_update_issue_model_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_issue_model), - '__call__') as call: - client.update_issue_model() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UpdateIssueModelRequest() - -@pytest.mark.asyncio -async def test_update_issue_model_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UpdateIssueModelRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.IssueModel( - name='name_value', - display_name='display_name_value', - issue_count=1201, - state=resources.IssueModel.State.UNDEPLOYED, - model_type=resources.IssueModel.ModelType.TYPE_V1, - language_code='language_code_value', - )) - response = await client.update_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UpdateIssueModelRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.IssueModel) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.issue_count == 1201 - assert response.state == resources.IssueModel.State.UNDEPLOYED - assert response.model_type == resources.IssueModel.ModelType.TYPE_V1 - assert response.language_code == 'language_code_value' - - -@pytest.mark.asyncio -async def test_update_issue_model_async_from_dict(): - await test_update_issue_model_async(request_type=dict) - - -def test_update_issue_model_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.UpdateIssueModelRequest() - - request.issue_model.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_issue_model), - '__call__') as call: - call.return_value = resources.IssueModel() - client.update_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'issue_model.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_issue_model_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.UpdateIssueModelRequest() - - request.issue_model.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_issue_model), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IssueModel()) - await client.update_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'issue_model.name=name_value', - ) in kw['metadata'] - - -def test_update_issue_model_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.IssueModel() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_issue_model( - issue_model=resources.IssueModel(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].issue_model - mock_val = resources.IssueModel(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - - -def test_update_issue_model_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_issue_model( - contact_center_insights.UpdateIssueModelRequest(), - issue_model=resources.IssueModel(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_issue_model_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.IssueModel() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IssueModel()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_issue_model( - issue_model=resources.IssueModel(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].issue_model - mock_val = resources.IssueModel(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - -@pytest.mark.asyncio -async def test_update_issue_model_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_issue_model( - contact_center_insights.UpdateIssueModelRequest(), - issue_model=resources.IssueModel(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.GetIssueModelRequest, - dict, -]) -def test_get_issue_model(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.IssueModel( - name='name_value', - display_name='display_name_value', - issue_count=1201, - state=resources.IssueModel.State.UNDEPLOYED, - model_type=resources.IssueModel.ModelType.TYPE_V1, - language_code='language_code_value', - ) - response = client.get_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetIssueModelRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.IssueModel) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.issue_count == 1201 - assert response.state == resources.IssueModel.State.UNDEPLOYED - assert response.model_type == resources.IssueModel.ModelType.TYPE_V1 - assert response.language_code == 'language_code_value' - - -def test_get_issue_model_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_issue_model), - '__call__') as call: - client.get_issue_model() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetIssueModelRequest() - -@pytest.mark.asyncio -async def test_get_issue_model_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.GetIssueModelRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.IssueModel( - name='name_value', - display_name='display_name_value', - issue_count=1201, - state=resources.IssueModel.State.UNDEPLOYED, - model_type=resources.IssueModel.ModelType.TYPE_V1, - language_code='language_code_value', - )) - response = await client.get_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetIssueModelRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.IssueModel) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.issue_count == 1201 - assert response.state == resources.IssueModel.State.UNDEPLOYED - assert response.model_type == resources.IssueModel.ModelType.TYPE_V1 - assert response.language_code == 'language_code_value' - - -@pytest.mark.asyncio -async def test_get_issue_model_async_from_dict(): - await test_get_issue_model_async(request_type=dict) - - -def test_get_issue_model_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.GetIssueModelRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_issue_model), - '__call__') as call: - call.return_value = resources.IssueModel() - client.get_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_issue_model_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.GetIssueModelRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_issue_model), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IssueModel()) - await client.get_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_get_issue_model_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.IssueModel() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_issue_model( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_issue_model_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_issue_model( - contact_center_insights.GetIssueModelRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_issue_model_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.IssueModel() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.IssueModel()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_issue_model( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_issue_model_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_issue_model( - contact_center_insights.GetIssueModelRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.ListIssueModelsRequest, - dict, -]) -def test_list_issue_models(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_issue_models), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListIssueModelsResponse( - ) - response = client.list_issue_models(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListIssueModelsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, contact_center_insights.ListIssueModelsResponse) - - -def test_list_issue_models_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_issue_models), - '__call__') as call: - client.list_issue_models() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListIssueModelsRequest() - -@pytest.mark.asyncio -async def test_list_issue_models_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.ListIssueModelsRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_issue_models), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListIssueModelsResponse( - )) - response = await client.list_issue_models(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListIssueModelsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, contact_center_insights.ListIssueModelsResponse) - - -@pytest.mark.asyncio -async def test_list_issue_models_async_from_dict(): - await test_list_issue_models_async(request_type=dict) - - -def test_list_issue_models_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.ListIssueModelsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_issue_models), - '__call__') as call: - call.return_value = contact_center_insights.ListIssueModelsResponse() - client.list_issue_models(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_list_issue_models_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.ListIssueModelsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_issue_models), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListIssueModelsResponse()) - await client.list_issue_models(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_list_issue_models_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_issue_models), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListIssueModelsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_issue_models( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_list_issue_models_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_issue_models( - contact_center_insights.ListIssueModelsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_issue_models_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_issue_models), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListIssueModelsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListIssueModelsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_issue_models( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_issue_models_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_issue_models( - contact_center_insights.ListIssueModelsRequest(), - parent='parent_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.DeleteIssueModelRequest, - dict, -]) -def test_delete_issue_model(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeleteIssueModelRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_issue_model_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_issue_model), - '__call__') as call: - client.delete_issue_model() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeleteIssueModelRequest() - -@pytest.mark.asyncio -async def test_delete_issue_model_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.DeleteIssueModelRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.delete_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeleteIssueModelRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_issue_model_async_from_dict(): - await test_delete_issue_model_async(request_type=dict) - - -def test_delete_issue_model_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.DeleteIssueModelRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_issue_model), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_delete_issue_model_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.DeleteIssueModelRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_issue_model), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_delete_issue_model_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_issue_model( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_delete_issue_model_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_issue_model( - contact_center_insights.DeleteIssueModelRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_issue_model_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_issue_model( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_delete_issue_model_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_issue_model( - contact_center_insights.DeleteIssueModelRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.DeployIssueModelRequest, - dict, -]) -def test_deploy_issue_model(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.deploy_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.deploy_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeployIssueModelRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_deploy_issue_model_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.deploy_issue_model), - '__call__') as call: - client.deploy_issue_model() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeployIssueModelRequest() - -@pytest.mark.asyncio -async def test_deploy_issue_model_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.DeployIssueModelRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.deploy_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.deploy_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeployIssueModelRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_deploy_issue_model_async_from_dict(): - await test_deploy_issue_model_async(request_type=dict) - - -def test_deploy_issue_model_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.DeployIssueModelRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.deploy_issue_model), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.deploy_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_deploy_issue_model_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.DeployIssueModelRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.deploy_issue_model), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.deploy_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_deploy_issue_model_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.deploy_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.deploy_issue_model( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_deploy_issue_model_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.deploy_issue_model( - contact_center_insights.DeployIssueModelRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_deploy_issue_model_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.deploy_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.deploy_issue_model( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_deploy_issue_model_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.deploy_issue_model( - contact_center_insights.DeployIssueModelRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.UndeployIssueModelRequest, - dict, -]) -def test_undeploy_issue_model(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.undeploy_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.undeploy_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UndeployIssueModelRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_undeploy_issue_model_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.undeploy_issue_model), - '__call__') as call: - client.undeploy_issue_model() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UndeployIssueModelRequest() - -@pytest.mark.asyncio -async def test_undeploy_issue_model_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UndeployIssueModelRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.undeploy_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.undeploy_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UndeployIssueModelRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_undeploy_issue_model_async_from_dict(): - await test_undeploy_issue_model_async(request_type=dict) - - -def test_undeploy_issue_model_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.UndeployIssueModelRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.undeploy_issue_model), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.undeploy_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_undeploy_issue_model_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.UndeployIssueModelRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.undeploy_issue_model), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.undeploy_issue_model(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_undeploy_issue_model_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.undeploy_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.undeploy_issue_model( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_undeploy_issue_model_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.undeploy_issue_model( - contact_center_insights.UndeployIssueModelRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_undeploy_issue_model_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.undeploy_issue_model), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.undeploy_issue_model( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_undeploy_issue_model_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.undeploy_issue_model( - contact_center_insights.UndeployIssueModelRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.GetIssueRequest, - dict, -]) -def test_get_issue(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_issue), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Issue( - name='name_value', - display_name='display_name_value', - sample_utterances=['sample_utterances_value'], - ) - response = client.get_issue(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetIssueRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Issue) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.sample_utterances == ['sample_utterances_value'] - - -def test_get_issue_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_issue), - '__call__') as call: - client.get_issue() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetIssueRequest() - -@pytest.mark.asyncio -async def test_get_issue_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.GetIssueRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_issue), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Issue( - name='name_value', - display_name='display_name_value', - sample_utterances=['sample_utterances_value'], - )) - response = await client.get_issue(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetIssueRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Issue) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.sample_utterances == ['sample_utterances_value'] - - -@pytest.mark.asyncio -async def test_get_issue_async_from_dict(): - await test_get_issue_async(request_type=dict) - - -def test_get_issue_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.GetIssueRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_issue), - '__call__') as call: - call.return_value = resources.Issue() - client.get_issue(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_issue_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.GetIssueRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_issue), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Issue()) - await client.get_issue(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_get_issue_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_issue), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Issue() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_issue( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_issue_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_issue( - contact_center_insights.GetIssueRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_issue_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_issue), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Issue() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Issue()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_issue( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_issue_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_issue( - contact_center_insights.GetIssueRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.ListIssuesRequest, - dict, -]) -def test_list_issues(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_issues), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListIssuesResponse( - ) - response = client.list_issues(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListIssuesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, contact_center_insights.ListIssuesResponse) - - -def test_list_issues_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_issues), - '__call__') as call: - client.list_issues() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListIssuesRequest() - -@pytest.mark.asyncio -async def test_list_issues_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.ListIssuesRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_issues), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListIssuesResponse( - )) - response = await client.list_issues(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListIssuesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, contact_center_insights.ListIssuesResponse) - - -@pytest.mark.asyncio -async def test_list_issues_async_from_dict(): - await test_list_issues_async(request_type=dict) - - -def test_list_issues_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.ListIssuesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_issues), - '__call__') as call: - call.return_value = contact_center_insights.ListIssuesResponse() - client.list_issues(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_list_issues_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.ListIssuesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_issues), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListIssuesResponse()) - await client.list_issues(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_list_issues_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_issues), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListIssuesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_issues( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_list_issues_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_issues( - contact_center_insights.ListIssuesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_issues_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_issues), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListIssuesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListIssuesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_issues( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_issues_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_issues( - contact_center_insights.ListIssuesRequest(), - parent='parent_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.UpdateIssueRequest, - dict, -]) -def test_update_issue(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_issue), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Issue( - name='name_value', - display_name='display_name_value', - sample_utterances=['sample_utterances_value'], - ) - response = client.update_issue(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UpdateIssueRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Issue) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.sample_utterances == ['sample_utterances_value'] - - -def test_update_issue_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_issue), - '__call__') as call: - client.update_issue() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UpdateIssueRequest() - -@pytest.mark.asyncio -async def test_update_issue_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UpdateIssueRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_issue), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Issue( - name='name_value', - display_name='display_name_value', - sample_utterances=['sample_utterances_value'], - )) - response = await client.update_issue(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UpdateIssueRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Issue) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.sample_utterances == ['sample_utterances_value'] - - -@pytest.mark.asyncio -async def test_update_issue_async_from_dict(): - await test_update_issue_async(request_type=dict) - - -def test_update_issue_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.UpdateIssueRequest() - - request.issue.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_issue), - '__call__') as call: - call.return_value = resources.Issue() - client.update_issue(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'issue.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_issue_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.UpdateIssueRequest() - - request.issue.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_issue), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Issue()) - await client.update_issue(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'issue.name=name_value', - ) in kw['metadata'] - - -def test_update_issue_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_issue), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Issue() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_issue( - issue=resources.Issue(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].issue - mock_val = resources.Issue(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - - -def test_update_issue_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_issue( - contact_center_insights.UpdateIssueRequest(), - issue=resources.Issue(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_issue_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_issue), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Issue() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Issue()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_issue( - issue=resources.Issue(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].issue - mock_val = resources.Issue(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - -@pytest.mark.asyncio -async def test_update_issue_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_issue( - contact_center_insights.UpdateIssueRequest(), - issue=resources.Issue(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.DeleteIssueRequest, - dict, -]) -def test_delete_issue(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_issue), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_issue(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeleteIssueRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_issue_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_issue), - '__call__') as call: - client.delete_issue() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeleteIssueRequest() - -@pytest.mark.asyncio -async def test_delete_issue_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.DeleteIssueRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_issue), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_issue(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeleteIssueRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_issue_async_from_dict(): - await test_delete_issue_async(request_type=dict) - - -def test_delete_issue_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.DeleteIssueRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_issue), - '__call__') as call: - call.return_value = None - client.delete_issue(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_delete_issue_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.DeleteIssueRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_issue), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_issue(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_delete_issue_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_issue), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_issue( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_delete_issue_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_issue( - contact_center_insights.DeleteIssueRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_issue_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_issue), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_issue( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_delete_issue_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_issue( - contact_center_insights.DeleteIssueRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.CalculateIssueModelStatsRequest, - dict, -]) -def test_calculate_issue_model_stats(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.calculate_issue_model_stats), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.CalculateIssueModelStatsResponse( - ) - response = client.calculate_issue_model_stats(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CalculateIssueModelStatsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, contact_center_insights.CalculateIssueModelStatsResponse) - - -def test_calculate_issue_model_stats_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.calculate_issue_model_stats), - '__call__') as call: - client.calculate_issue_model_stats() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CalculateIssueModelStatsRequest() - -@pytest.mark.asyncio -async def test_calculate_issue_model_stats_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.CalculateIssueModelStatsRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.calculate_issue_model_stats), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.CalculateIssueModelStatsResponse( - )) - response = await client.calculate_issue_model_stats(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CalculateIssueModelStatsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, contact_center_insights.CalculateIssueModelStatsResponse) - - -@pytest.mark.asyncio -async def test_calculate_issue_model_stats_async_from_dict(): - await test_calculate_issue_model_stats_async(request_type=dict) - - -def test_calculate_issue_model_stats_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.CalculateIssueModelStatsRequest() - - request.issue_model = 'issue_model_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.calculate_issue_model_stats), - '__call__') as call: - call.return_value = contact_center_insights.CalculateIssueModelStatsResponse() - client.calculate_issue_model_stats(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'issue_model=issue_model_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_calculate_issue_model_stats_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.CalculateIssueModelStatsRequest() - - request.issue_model = 'issue_model_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.calculate_issue_model_stats), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.CalculateIssueModelStatsResponse()) - await client.calculate_issue_model_stats(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'issue_model=issue_model_value', - ) in kw['metadata'] - - -def test_calculate_issue_model_stats_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.calculate_issue_model_stats), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.CalculateIssueModelStatsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.calculate_issue_model_stats( - issue_model='issue_model_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].issue_model - mock_val = 'issue_model_value' - assert arg == mock_val - - -def test_calculate_issue_model_stats_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.calculate_issue_model_stats( - contact_center_insights.CalculateIssueModelStatsRequest(), - issue_model='issue_model_value', - ) - -@pytest.mark.asyncio -async def test_calculate_issue_model_stats_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.calculate_issue_model_stats), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.CalculateIssueModelStatsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.CalculateIssueModelStatsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.calculate_issue_model_stats( - issue_model='issue_model_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].issue_model - mock_val = 'issue_model_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_calculate_issue_model_stats_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.calculate_issue_model_stats( - contact_center_insights.CalculateIssueModelStatsRequest(), - issue_model='issue_model_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.CreatePhraseMatcherRequest, - dict, -]) -def test_create_phrase_matcher(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_phrase_matcher), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.PhraseMatcher( - name='name_value', - revision_id='revision_id_value', - version_tag='version_tag_value', - display_name='display_name_value', - type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, - active=True, - role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, - ) - response = client.create_phrase_matcher(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CreatePhraseMatcherRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.PhraseMatcher) - assert response.name == 'name_value' - assert response.revision_id == 'revision_id_value' - assert response.version_tag == 'version_tag_value' - assert response.display_name == 'display_name_value' - assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF - assert response.active is True - assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT - - -def test_create_phrase_matcher_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_phrase_matcher), - '__call__') as call: - client.create_phrase_matcher() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CreatePhraseMatcherRequest() - -@pytest.mark.asyncio -async def test_create_phrase_matcher_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.CreatePhraseMatcherRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_phrase_matcher), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher( - name='name_value', - revision_id='revision_id_value', - version_tag='version_tag_value', - display_name='display_name_value', - type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, - active=True, - role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, - )) - response = await client.create_phrase_matcher(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CreatePhraseMatcherRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.PhraseMatcher) - assert response.name == 'name_value' - assert response.revision_id == 'revision_id_value' - assert response.version_tag == 'version_tag_value' - assert response.display_name == 'display_name_value' - assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF - assert response.active is True - assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT - - -@pytest.mark.asyncio -async def test_create_phrase_matcher_async_from_dict(): - await test_create_phrase_matcher_async(request_type=dict) - - -def test_create_phrase_matcher_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.CreatePhraseMatcherRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_phrase_matcher), - '__call__') as call: - call.return_value = resources.PhraseMatcher() - client.create_phrase_matcher(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_create_phrase_matcher_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.CreatePhraseMatcherRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_phrase_matcher), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher()) - await client.create_phrase_matcher(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_create_phrase_matcher_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_phrase_matcher), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.PhraseMatcher() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_phrase_matcher( - parent='parent_value', - phrase_matcher=resources.PhraseMatcher(name='name_value'), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].phrase_matcher - mock_val = resources.PhraseMatcher(name='name_value') - assert arg == mock_val - - -def test_create_phrase_matcher_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_phrase_matcher( - contact_center_insights.CreatePhraseMatcherRequest(), - parent='parent_value', - phrase_matcher=resources.PhraseMatcher(name='name_value'), - ) - -@pytest.mark.asyncio -async def test_create_phrase_matcher_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_phrase_matcher), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.PhraseMatcher() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_phrase_matcher( - parent='parent_value', - phrase_matcher=resources.PhraseMatcher(name='name_value'), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].phrase_matcher - mock_val = resources.PhraseMatcher(name='name_value') - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_phrase_matcher_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_phrase_matcher( - contact_center_insights.CreatePhraseMatcherRequest(), - parent='parent_value', - phrase_matcher=resources.PhraseMatcher(name='name_value'), - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.GetPhraseMatcherRequest, - dict, -]) -def test_get_phrase_matcher(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_phrase_matcher), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.PhraseMatcher( - name='name_value', - revision_id='revision_id_value', - version_tag='version_tag_value', - display_name='display_name_value', - type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, - active=True, - role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, - ) - response = client.get_phrase_matcher(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetPhraseMatcherRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.PhraseMatcher) - assert response.name == 'name_value' - assert response.revision_id == 'revision_id_value' - assert response.version_tag == 'version_tag_value' - assert response.display_name == 'display_name_value' - assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF - assert response.active is True - assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT - - -def test_get_phrase_matcher_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_phrase_matcher), - '__call__') as call: - client.get_phrase_matcher() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetPhraseMatcherRequest() - -@pytest.mark.asyncio -async def test_get_phrase_matcher_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.GetPhraseMatcherRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_phrase_matcher), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher( - name='name_value', - revision_id='revision_id_value', - version_tag='version_tag_value', - display_name='display_name_value', - type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, - active=True, - role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, - )) - response = await client.get_phrase_matcher(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetPhraseMatcherRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.PhraseMatcher) - assert response.name == 'name_value' - assert response.revision_id == 'revision_id_value' - assert response.version_tag == 'version_tag_value' - assert response.display_name == 'display_name_value' - assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF - assert response.active is True - assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT - - -@pytest.mark.asyncio -async def test_get_phrase_matcher_async_from_dict(): - await test_get_phrase_matcher_async(request_type=dict) - - -def test_get_phrase_matcher_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.GetPhraseMatcherRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_phrase_matcher), - '__call__') as call: - call.return_value = resources.PhraseMatcher() - client.get_phrase_matcher(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_phrase_matcher_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.GetPhraseMatcherRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_phrase_matcher), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher()) - await client.get_phrase_matcher(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_get_phrase_matcher_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_phrase_matcher), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.PhraseMatcher() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_phrase_matcher( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_phrase_matcher_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_phrase_matcher( - contact_center_insights.GetPhraseMatcherRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_phrase_matcher_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_phrase_matcher), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.PhraseMatcher() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_phrase_matcher( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_phrase_matcher_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_phrase_matcher( - contact_center_insights.GetPhraseMatcherRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.ListPhraseMatchersRequest, - dict, -]) -def test_list_phrase_matchers(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_phrase_matchers), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListPhraseMatchersResponse( - next_page_token='next_page_token_value', - ) - response = client.list_phrase_matchers(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListPhraseMatchersRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPhraseMatchersPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_phrase_matchers_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_phrase_matchers), - '__call__') as call: - client.list_phrase_matchers() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListPhraseMatchersRequest() - -@pytest.mark.asyncio -async def test_list_phrase_matchers_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.ListPhraseMatchersRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_phrase_matchers), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListPhraseMatchersResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_phrase_matchers(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListPhraseMatchersRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPhraseMatchersAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_phrase_matchers_async_from_dict(): - await test_list_phrase_matchers_async(request_type=dict) - - -def test_list_phrase_matchers_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.ListPhraseMatchersRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_phrase_matchers), - '__call__') as call: - call.return_value = contact_center_insights.ListPhraseMatchersResponse() - client.list_phrase_matchers(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_list_phrase_matchers_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.ListPhraseMatchersRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_phrase_matchers), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListPhraseMatchersResponse()) - await client.list_phrase_matchers(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_list_phrase_matchers_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_phrase_matchers), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListPhraseMatchersResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_phrase_matchers( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_list_phrase_matchers_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_phrase_matchers( - contact_center_insights.ListPhraseMatchersRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_phrase_matchers_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_phrase_matchers), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListPhraseMatchersResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListPhraseMatchersResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_phrase_matchers( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_phrase_matchers_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_phrase_matchers( - contact_center_insights.ListPhraseMatchersRequest(), - parent='parent_value', - ) - - -def test_list_phrase_matchers_pager(transport_name: str = "grpc"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_phrase_matchers), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[ - resources.PhraseMatcher(), - resources.PhraseMatcher(), - resources.PhraseMatcher(), - ], - next_page_token='abc', - ), - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[], - next_page_token='def', - ), - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[ - resources.PhraseMatcher(), - ], - next_page_token='ghi', - ), - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[ - resources.PhraseMatcher(), - resources.PhraseMatcher(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_phrase_matchers(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.PhraseMatcher) - for i in results) -def test_list_phrase_matchers_pages(transport_name: str = "grpc"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_phrase_matchers), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[ - resources.PhraseMatcher(), - resources.PhraseMatcher(), - resources.PhraseMatcher(), - ], - next_page_token='abc', - ), - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[], - next_page_token='def', - ), - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[ - resources.PhraseMatcher(), - ], - next_page_token='ghi', - ), - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[ - resources.PhraseMatcher(), - resources.PhraseMatcher(), - ], - ), - RuntimeError, - ) - pages = list(client.list_phrase_matchers(request={}).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.asyncio -async def test_list_phrase_matchers_async_pager(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_phrase_matchers), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[ - resources.PhraseMatcher(), - resources.PhraseMatcher(), - resources.PhraseMatcher(), - ], - next_page_token='abc', - ), - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[], - next_page_token='def', - ), - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[ - resources.PhraseMatcher(), - ], - next_page_token='ghi', - ), - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[ - resources.PhraseMatcher(), - resources.PhraseMatcher(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_phrase_matchers(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, resources.PhraseMatcher) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_phrase_matchers_async_pages(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_phrase_matchers), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[ - resources.PhraseMatcher(), - resources.PhraseMatcher(), - resources.PhraseMatcher(), - ], - next_page_token='abc', - ), - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[], - next_page_token='def', - ), - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[ - resources.PhraseMatcher(), - ], - next_page_token='ghi', - ), - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[ - resources.PhraseMatcher(), - resources.PhraseMatcher(), - ], - ), - RuntimeError, - ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_phrase_matchers(request={}) - ).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.DeletePhraseMatcherRequest, - dict, -]) -def test_delete_phrase_matcher(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_phrase_matcher), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_phrase_matcher(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeletePhraseMatcherRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_phrase_matcher_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_phrase_matcher), - '__call__') as call: - client.delete_phrase_matcher() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeletePhraseMatcherRequest() - -@pytest.mark.asyncio -async def test_delete_phrase_matcher_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.DeletePhraseMatcherRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_phrase_matcher), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_phrase_matcher(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeletePhraseMatcherRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_phrase_matcher_async_from_dict(): - await test_delete_phrase_matcher_async(request_type=dict) - - -def test_delete_phrase_matcher_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.DeletePhraseMatcherRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_phrase_matcher), - '__call__') as call: - call.return_value = None - client.delete_phrase_matcher(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_delete_phrase_matcher_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.DeletePhraseMatcherRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_phrase_matcher), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_phrase_matcher(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_delete_phrase_matcher_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_phrase_matcher), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_phrase_matcher( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_delete_phrase_matcher_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_phrase_matcher( - contact_center_insights.DeletePhraseMatcherRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_phrase_matcher_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_phrase_matcher), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_phrase_matcher( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_delete_phrase_matcher_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_phrase_matcher( - contact_center_insights.DeletePhraseMatcherRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.UpdatePhraseMatcherRequest, - dict, -]) -def test_update_phrase_matcher(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_phrase_matcher), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.PhraseMatcher( - name='name_value', - revision_id='revision_id_value', - version_tag='version_tag_value', - display_name='display_name_value', - type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, - active=True, - role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, - ) - response = client.update_phrase_matcher(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UpdatePhraseMatcherRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.PhraseMatcher) - assert response.name == 'name_value' - assert response.revision_id == 'revision_id_value' - assert response.version_tag == 'version_tag_value' - assert response.display_name == 'display_name_value' - assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF - assert response.active is True - assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT - - -def test_update_phrase_matcher_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_phrase_matcher), - '__call__') as call: - client.update_phrase_matcher() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UpdatePhraseMatcherRequest() - -@pytest.mark.asyncio -async def test_update_phrase_matcher_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UpdatePhraseMatcherRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_phrase_matcher), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher( - name='name_value', - revision_id='revision_id_value', - version_tag='version_tag_value', - display_name='display_name_value', - type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, - active=True, - role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, - )) - response = await client.update_phrase_matcher(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UpdatePhraseMatcherRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.PhraseMatcher) - assert response.name == 'name_value' - assert response.revision_id == 'revision_id_value' - assert response.version_tag == 'version_tag_value' - assert response.display_name == 'display_name_value' - assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF - assert response.active is True - assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT - - -@pytest.mark.asyncio -async def test_update_phrase_matcher_async_from_dict(): - await test_update_phrase_matcher_async(request_type=dict) - - -def test_update_phrase_matcher_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.UpdatePhraseMatcherRequest() - - request.phrase_matcher.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_phrase_matcher), - '__call__') as call: - call.return_value = resources.PhraseMatcher() - client.update_phrase_matcher(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'phrase_matcher.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_phrase_matcher_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.UpdatePhraseMatcherRequest() - - request.phrase_matcher.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_phrase_matcher), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher()) - await client.update_phrase_matcher(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'phrase_matcher.name=name_value', - ) in kw['metadata'] - - -def test_update_phrase_matcher_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_phrase_matcher), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.PhraseMatcher() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_phrase_matcher( - phrase_matcher=resources.PhraseMatcher(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].phrase_matcher - mock_val = resources.PhraseMatcher(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - - -def test_update_phrase_matcher_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_phrase_matcher( - contact_center_insights.UpdatePhraseMatcherRequest(), - phrase_matcher=resources.PhraseMatcher(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_phrase_matcher_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_phrase_matcher), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.PhraseMatcher() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.PhraseMatcher()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_phrase_matcher( - phrase_matcher=resources.PhraseMatcher(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].phrase_matcher - mock_val = resources.PhraseMatcher(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - -@pytest.mark.asyncio -async def test_update_phrase_matcher_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_phrase_matcher( - contact_center_insights.UpdatePhraseMatcherRequest(), - phrase_matcher=resources.PhraseMatcher(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.CalculateStatsRequest, - dict, -]) -def test_calculate_stats(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.calculate_stats), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.CalculateStatsResponse( - average_turn_count=1931, - conversation_count=1955, - ) - response = client.calculate_stats(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CalculateStatsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, contact_center_insights.CalculateStatsResponse) - assert response.average_turn_count == 1931 - assert response.conversation_count == 1955 - - -def test_calculate_stats_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.calculate_stats), - '__call__') as call: - client.calculate_stats() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CalculateStatsRequest() - -@pytest.mark.asyncio -async def test_calculate_stats_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.CalculateStatsRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.calculate_stats), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.CalculateStatsResponse( - average_turn_count=1931, - conversation_count=1955, - )) - response = await client.calculate_stats(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CalculateStatsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, contact_center_insights.CalculateStatsResponse) - assert response.average_turn_count == 1931 - assert response.conversation_count == 1955 - - -@pytest.mark.asyncio -async def test_calculate_stats_async_from_dict(): - await test_calculate_stats_async(request_type=dict) - - -def test_calculate_stats_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.CalculateStatsRequest() - - request.location = 'location_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.calculate_stats), - '__call__') as call: - call.return_value = contact_center_insights.CalculateStatsResponse() - client.calculate_stats(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'location=location_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_calculate_stats_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.CalculateStatsRequest() - - request.location = 'location_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.calculate_stats), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.CalculateStatsResponse()) - await client.calculate_stats(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'location=location_value', - ) in kw['metadata'] - - -def test_calculate_stats_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.calculate_stats), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.CalculateStatsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.calculate_stats( - location='location_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].location - mock_val = 'location_value' - assert arg == mock_val - - -def test_calculate_stats_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.calculate_stats( - contact_center_insights.CalculateStatsRequest(), - location='location_value', - ) - -@pytest.mark.asyncio -async def test_calculate_stats_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.calculate_stats), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.CalculateStatsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.CalculateStatsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.calculate_stats( - location='location_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].location - mock_val = 'location_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_calculate_stats_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.calculate_stats( - contact_center_insights.CalculateStatsRequest(), - location='location_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.GetSettingsRequest, - dict, -]) -def test_get_settings(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Settings( - name='name_value', - language_code='language_code_value', - ) - response = client.get_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetSettingsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Settings) - assert response.name == 'name_value' - assert response.language_code == 'language_code_value' - - -def test_get_settings_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_settings), - '__call__') as call: - client.get_settings() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetSettingsRequest() - -@pytest.mark.asyncio -async def test_get_settings_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.GetSettingsRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Settings( - name='name_value', - language_code='language_code_value', - )) - response = await client.get_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetSettingsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Settings) - assert response.name == 'name_value' - assert response.language_code == 'language_code_value' - - -@pytest.mark.asyncio -async def test_get_settings_async_from_dict(): - await test_get_settings_async(request_type=dict) - - -def test_get_settings_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.GetSettingsRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_settings), - '__call__') as call: - call.return_value = resources.Settings() - client.get_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_settings_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.GetSettingsRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_settings), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Settings()) - await client.get_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_get_settings_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Settings() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_settings( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_settings_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_settings( - contact_center_insights.GetSettingsRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_settings_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Settings() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Settings()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_settings( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_settings_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_settings( - contact_center_insights.GetSettingsRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.UpdateSettingsRequest, - dict, -]) -def test_update_settings(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Settings( - name='name_value', - language_code='language_code_value', - ) - response = client.update_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UpdateSettingsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Settings) - assert response.name == 'name_value' - assert response.language_code == 'language_code_value' - - -def test_update_settings_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_settings), - '__call__') as call: - client.update_settings() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UpdateSettingsRequest() - -@pytest.mark.asyncio -async def test_update_settings_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UpdateSettingsRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.Settings( - name='name_value', - language_code='language_code_value', - )) - response = await client.update_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UpdateSettingsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Settings) - assert response.name == 'name_value' - assert response.language_code == 'language_code_value' - - -@pytest.mark.asyncio -async def test_update_settings_async_from_dict(): - await test_update_settings_async(request_type=dict) - - -def test_update_settings_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.UpdateSettingsRequest() - - request.settings.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_settings), - '__call__') as call: - call.return_value = resources.Settings() - client.update_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'settings.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_settings_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.UpdateSettingsRequest() - - request.settings.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_settings), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Settings()) - await client.update_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'settings.name=name_value', - ) in kw['metadata'] - - -def test_update_settings_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Settings() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_settings( - settings=resources.Settings(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].settings - mock_val = resources.Settings(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - - -def test_update_settings_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_settings( - contact_center_insights.UpdateSettingsRequest(), - settings=resources.Settings(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_settings_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.Settings() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Settings()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_settings( - settings=resources.Settings(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].settings - mock_val = resources.Settings(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - -@pytest.mark.asyncio -async def test_update_settings_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_settings( - contact_center_insights.UpdateSettingsRequest(), - settings=resources.Settings(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.CreateViewRequest, - dict, -]) -def test_create_view(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_view), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.View( - name='name_value', - display_name='display_name_value', - value='value_value', - ) - response = client.create_view(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CreateViewRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.View) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.value == 'value_value' - - -def test_create_view_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_view), - '__call__') as call: - client.create_view() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CreateViewRequest() - -@pytest.mark.asyncio -async def test_create_view_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.CreateViewRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_view), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.View( - name='name_value', - display_name='display_name_value', - value='value_value', - )) - response = await client.create_view(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.CreateViewRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.View) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.value == 'value_value' - - -@pytest.mark.asyncio -async def test_create_view_async_from_dict(): - await test_create_view_async(request_type=dict) - - -def test_create_view_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.CreateViewRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_view), - '__call__') as call: - call.return_value = resources.View() - client.create_view(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_create_view_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.CreateViewRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_view), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) - await client.create_view(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_create_view_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_view), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.View() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_view( - parent='parent_value', - view=resources.View(name='name_value'), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].view - mock_val = resources.View(name='name_value') - assert arg == mock_val - - -def test_create_view_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_view( - contact_center_insights.CreateViewRequest(), - parent='parent_value', - view=resources.View(name='name_value'), - ) - -@pytest.mark.asyncio -async def test_create_view_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_view), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.View() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_view( - parent='parent_value', - view=resources.View(name='name_value'), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].view - mock_val = resources.View(name='name_value') - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_view_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_view( - contact_center_insights.CreateViewRequest(), - parent='parent_value', - view=resources.View(name='name_value'), - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.GetViewRequest, - dict, -]) -def test_get_view(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_view), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.View( - name='name_value', - display_name='display_name_value', - value='value_value', - ) - response = client.get_view(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetViewRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.View) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.value == 'value_value' - - -def test_get_view_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_view), - '__call__') as call: - client.get_view() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetViewRequest() - -@pytest.mark.asyncio -async def test_get_view_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.GetViewRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_view), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.View( - name='name_value', - display_name='display_name_value', - value='value_value', - )) - response = await client.get_view(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetViewRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.View) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.value == 'value_value' - - -@pytest.mark.asyncio -async def test_get_view_async_from_dict(): - await test_get_view_async(request_type=dict) - - -def test_get_view_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.GetViewRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_view), - '__call__') as call: - call.return_value = resources.View() - client.get_view(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_view_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.GetViewRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_view), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) - await client.get_view(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_get_view_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_view), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.View() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_view( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_view_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_view( - contact_center_insights.GetViewRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_view_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_view), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.View() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_view( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_view_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_view( - contact_center_insights.GetViewRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.ListViewsRequest, - dict, -]) -def test_list_views(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_views), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListViewsResponse( - next_page_token='next_page_token_value', - ) - response = client.list_views(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListViewsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListViewsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_views_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_views), - '__call__') as call: - client.list_views() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListViewsRequest() - -@pytest.mark.asyncio -async def test_list_views_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.ListViewsRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_views), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListViewsResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_views(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListViewsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListViewsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_views_async_from_dict(): - await test_list_views_async(request_type=dict) - - -def test_list_views_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.ListViewsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_views), - '__call__') as call: - call.return_value = contact_center_insights.ListViewsResponse() - client.list_views(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_list_views_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.ListViewsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_views), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListViewsResponse()) - await client.list_views(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_list_views_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_views), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListViewsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_views( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_list_views_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_views( - contact_center_insights.ListViewsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_views_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_views), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListViewsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(contact_center_insights.ListViewsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_views( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_views_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_views( - contact_center_insights.ListViewsRequest(), - parent='parent_value', - ) - - -def test_list_views_pager(transport_name: str = "grpc"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_views), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - resources.View(), - resources.View(), - ], - next_page_token='abc', - ), - contact_center_insights.ListViewsResponse( - views=[], - next_page_token='def', - ), - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - ], - next_page_token='ghi', - ), - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - resources.View(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_views(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.View) - for i in results) -def test_list_views_pages(transport_name: str = "grpc"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_views), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - resources.View(), - resources.View(), - ], - next_page_token='abc', - ), - contact_center_insights.ListViewsResponse( - views=[], - next_page_token='def', - ), - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - ], - next_page_token='ghi', - ), - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - resources.View(), - ], - ), - RuntimeError, - ) - pages = list(client.list_views(request={}).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.asyncio -async def test_list_views_async_pager(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_views), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - resources.View(), - resources.View(), - ], - next_page_token='abc', - ), - contact_center_insights.ListViewsResponse( - views=[], - next_page_token='def', - ), - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - ], - next_page_token='ghi', - ), - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - resources.View(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_views(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, resources.View) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_views_async_pages(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_views), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - resources.View(), - resources.View(), - ], - next_page_token='abc', - ), - contact_center_insights.ListViewsResponse( - views=[], - next_page_token='def', - ), - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - ], - next_page_token='ghi', - ), - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - resources.View(), - ], - ), - RuntimeError, - ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_views(request={}) - ).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.UpdateViewRequest, - dict, -]) -def test_update_view(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_view), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.View( - name='name_value', - display_name='display_name_value', - value='value_value', - ) - response = client.update_view(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UpdateViewRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.View) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.value == 'value_value' - - -def test_update_view_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_view), - '__call__') as call: - client.update_view() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UpdateViewRequest() - -@pytest.mark.asyncio -async def test_update_view_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.UpdateViewRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_view), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(resources.View( - name='name_value', - display_name='display_name_value', - value='value_value', - )) - response = await client.update_view(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.UpdateViewRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.View) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.value == 'value_value' - - -@pytest.mark.asyncio -async def test_update_view_async_from_dict(): - await test_update_view_async(request_type=dict) - - -def test_update_view_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.UpdateViewRequest() - - request.view.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_view), - '__call__') as call: - call.return_value = resources.View() - client.update_view(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'view.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_view_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.UpdateViewRequest() - - request.view.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_view), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) - await client.update_view(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'view.name=name_value', - ) in kw['metadata'] - - -def test_update_view_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_view), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.View() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_view( - view=resources.View(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].view - mock_val = resources.View(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - - -def test_update_view_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_view( - contact_center_insights.UpdateViewRequest(), - view=resources.View(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_view_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_view), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = resources.View() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.View()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_view( - view=resources.View(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].view - mock_val = resources.View(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - -@pytest.mark.asyncio -async def test_update_view_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_view( - contact_center_insights.UpdateViewRequest(), - view=resources.View(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.DeleteViewRequest, - dict, -]) -def test_delete_view(request_type, transport: str = 'grpc'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_view), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_view(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeleteViewRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_view_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_view), - '__call__') as call: - client.delete_view() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeleteViewRequest() - -@pytest.mark.asyncio -async def test_delete_view_async(transport: str = 'grpc_asyncio', request_type=contact_center_insights.DeleteViewRequest): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_view), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_view(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.DeleteViewRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_view_async_from_dict(): - await test_delete_view_async(request_type=dict) - - -def test_delete_view_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.DeleteViewRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_view), - '__call__') as call: - call.return_value = None - client.delete_view(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_delete_view_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = contact_center_insights.DeleteViewRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_view), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_view(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_delete_view_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_view), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_view( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_delete_view_flattened_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_view( - contact_center_insights.DeleteViewRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_view_flattened_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_view), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_view( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_delete_view_flattened_error_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_view( - contact_center_insights.DeleteViewRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.CreateConversationRequest, - dict, -]) -def test_create_conversation_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["conversation"] = {'call_metadata': {'customer_channel': 1706, 'agent_channel': 1351}, 'expire_time': {'seconds': 751, 'nanos': 543}, 'ttl': {'seconds': 751, 'nanos': 543}, 'name': 'name_value', 'data_source': {'gcs_source': {'audio_uri': 'audio_uri_value', 'transcript_uri': 'transcript_uri_value'}, 'dialogflow_source': {'dialogflow_conversation': 'dialogflow_conversation_value', 'audio_uri': 'audio_uri_value'}}, 'create_time': {}, 'update_time': {}, 'start_time': {}, 'language_code': 'language_code_value', 'agent_id': 'agent_id_value', 'labels': {}, 'transcript': {'transcript_segments': [{'message_time': {}, 'text': 'text_value', 'confidence': 0.1038, 'words': [{'start_offset': {}, 'end_offset': {}, 'word': 'word_value', 'confidence': 0.1038}], 'language_code': 'language_code_value', 'channel_tag': 1140, 'segment_participant': {'dialogflow_participant_name': 'dialogflow_participant_name_value', 'user_id': 'user_id_value', 'dialogflow_participant': 'dialogflow_participant_value', 'obfuscated_external_user_id': 'obfuscated_external_user_id_value', 'role': 1}, 'dialogflow_segment_metadata': {'smart_reply_allowlist_covered': True}, 'sentiment': {'magnitude': 0.9580000000000001, 'score': 0.54}}]}, 'medium': 1, 'duration': {}, 'turn_count': 1105, 'latest_analysis': {'name': 'name_value', 'request_time': {}, 'create_time': {}, 'analysis_result': {'call_analysis_metadata': {'annotations': [{'interruption_data': {}, 'sentiment_data': {}, 'silence_data': {}, 'hold_data': {}, 'entity_mention_data': {'entity_unique_id': 'entity_unique_id_value', 'type_': 1, 'sentiment': {}}, 'intent_match_data': {'intent_unique_id': 'intent_unique_id_value'}, 'phrase_match_data': {'phrase_matcher': 'phrase_matcher_value', 'display_name': 'display_name_value'}, 'issue_match_data': {'issue_assignment': {'issue': 'issue_value', 'score': 0.54, 'display_name': 'display_name_value'}}, 'channel_tag': 1140, 'annotation_start_boundary': {'word_index': 1075, 'transcript_index': 1729}, 'annotation_end_boundary': {}}], 'entities': {}, 'sentiments': [{'channel_tag': 1140, 'sentiment_data': {}}], 'intents': {}, 'phrase_matchers': {}, 'issue_model_result': {'issue_model': 'issue_model_value', 'issues': {}}}, 'end_time': {}}, 'annotator_selector': {'run_interruption_annotator': True, 'run_silence_annotator': True, 'run_phrase_matcher_annotator': True, 'phrase_matchers': ['phrase_matchers_value1', 'phrase_matchers_value2'], 'run_sentiment_annotator': True, 'run_entity_annotator': True, 'run_intent_annotator': True, 'run_issue_model_annotator': True, 'issue_models': ['issue_models_value1', 'issue_models_value2'], 'run_summarization_annotator': True, 'summarization_config': {'conversation_profile': 'conversation_profile_value', 'summarization_model': 1}}}, 'latest_summary': {'text': 'text_value', 'text_sections': {}, 'confidence': 0.1038, 'metadata': {}, 'answer_record': 'answer_record_value', 'conversation_model': 'conversation_model_value'}, 'runtime_annotations': [{'article_suggestion': {'title': 'title_value', 'uri': 'uri_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value', 'source': 'source_value'}, 'faq_answer': {'answer': 'answer_value', 'confidence_score': 0.1673, 'question': 'question_value', 'metadata': {}, 'query_record': 'query_record_value', 'source': 'source_value'}, 'smart_reply': {'reply': 'reply_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value'}, 'smart_compose_suggestion': {'suggestion': 'suggestion_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value'}, 'dialogflow_interaction': {'dialogflow_intent_id': 'dialogflow_intent_id_value', 'confidence': 0.1038}, 'conversation_summarization_suggestion': {}, 'annotation_id': 'annotation_id_value', 'create_time': {}, 'start_boundary': {}, 'end_boundary': {}, 'answer_feedback': {'correctness_level': 1, 'clicked': True, 'displayed': True}}], 'dialogflow_intents': {}, 'obfuscated_user_id': 'obfuscated_user_id_value'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.Conversation( - name='name_value', - language_code='language_code_value', - agent_id='agent_id_value', - medium=resources.Conversation.Medium.PHONE_CALL, - turn_count=1105, - obfuscated_user_id='obfuscated_user_id_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.Conversation.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.create_conversation(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Conversation) - assert response.name == 'name_value' - assert response.language_code == 'language_code_value' - assert response.agent_id == 'agent_id_value' - assert response.medium == resources.Conversation.Medium.PHONE_CALL - assert response.turn_count == 1105 - assert response.obfuscated_user_id == 'obfuscated_user_id_value' - - -def test_create_conversation_rest_required_fields(request_type=contact_center_insights.CreateConversationRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_conversation._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_conversation._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("conversation_id", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.Conversation() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = resources.Conversation.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.create_conversation(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_conversation_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_conversation._get_unset_required_fields({}) - assert set(unset_fields) == (set(("conversationId", )) & set(("parent", "conversation", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_conversation_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_create_conversation") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_create_conversation") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.CreateConversationRequest.pb(contact_center_insights.CreateConversationRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = resources.Conversation.to_json(resources.Conversation()) - - request = contact_center_insights.CreateConversationRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = resources.Conversation() - - client.create_conversation(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_create_conversation_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.CreateConversationRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["conversation"] = {'call_metadata': {'customer_channel': 1706, 'agent_channel': 1351}, 'expire_time': {'seconds': 751, 'nanos': 543}, 'ttl': {'seconds': 751, 'nanos': 543}, 'name': 'name_value', 'data_source': {'gcs_source': {'audio_uri': 'audio_uri_value', 'transcript_uri': 'transcript_uri_value'}, 'dialogflow_source': {'dialogflow_conversation': 'dialogflow_conversation_value', 'audio_uri': 'audio_uri_value'}}, 'create_time': {}, 'update_time': {}, 'start_time': {}, 'language_code': 'language_code_value', 'agent_id': 'agent_id_value', 'labels': {}, 'transcript': {'transcript_segments': [{'message_time': {}, 'text': 'text_value', 'confidence': 0.1038, 'words': [{'start_offset': {}, 'end_offset': {}, 'word': 'word_value', 'confidence': 0.1038}], 'language_code': 'language_code_value', 'channel_tag': 1140, 'segment_participant': {'dialogflow_participant_name': 'dialogflow_participant_name_value', 'user_id': 'user_id_value', 'dialogflow_participant': 'dialogflow_participant_value', 'obfuscated_external_user_id': 'obfuscated_external_user_id_value', 'role': 1}, 'dialogflow_segment_metadata': {'smart_reply_allowlist_covered': True}, 'sentiment': {'magnitude': 0.9580000000000001, 'score': 0.54}}]}, 'medium': 1, 'duration': {}, 'turn_count': 1105, 'latest_analysis': {'name': 'name_value', 'request_time': {}, 'create_time': {}, 'analysis_result': {'call_analysis_metadata': {'annotations': [{'interruption_data': {}, 'sentiment_data': {}, 'silence_data': {}, 'hold_data': {}, 'entity_mention_data': {'entity_unique_id': 'entity_unique_id_value', 'type_': 1, 'sentiment': {}}, 'intent_match_data': {'intent_unique_id': 'intent_unique_id_value'}, 'phrase_match_data': {'phrase_matcher': 'phrase_matcher_value', 'display_name': 'display_name_value'}, 'issue_match_data': {'issue_assignment': {'issue': 'issue_value', 'score': 0.54, 'display_name': 'display_name_value'}}, 'channel_tag': 1140, 'annotation_start_boundary': {'word_index': 1075, 'transcript_index': 1729}, 'annotation_end_boundary': {}}], 'entities': {}, 'sentiments': [{'channel_tag': 1140, 'sentiment_data': {}}], 'intents': {}, 'phrase_matchers': {}, 'issue_model_result': {'issue_model': 'issue_model_value', 'issues': {}}}, 'end_time': {}}, 'annotator_selector': {'run_interruption_annotator': True, 'run_silence_annotator': True, 'run_phrase_matcher_annotator': True, 'phrase_matchers': ['phrase_matchers_value1', 'phrase_matchers_value2'], 'run_sentiment_annotator': True, 'run_entity_annotator': True, 'run_intent_annotator': True, 'run_issue_model_annotator': True, 'issue_models': ['issue_models_value1', 'issue_models_value2'], 'run_summarization_annotator': True, 'summarization_config': {'conversation_profile': 'conversation_profile_value', 'summarization_model': 1}}}, 'latest_summary': {'text': 'text_value', 'text_sections': {}, 'confidence': 0.1038, 'metadata': {}, 'answer_record': 'answer_record_value', 'conversation_model': 'conversation_model_value'}, 'runtime_annotations': [{'article_suggestion': {'title': 'title_value', 'uri': 'uri_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value', 'source': 'source_value'}, 'faq_answer': {'answer': 'answer_value', 'confidence_score': 0.1673, 'question': 'question_value', 'metadata': {}, 'query_record': 'query_record_value', 'source': 'source_value'}, 'smart_reply': {'reply': 'reply_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value'}, 'smart_compose_suggestion': {'suggestion': 'suggestion_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value'}, 'dialogflow_interaction': {'dialogflow_intent_id': 'dialogflow_intent_id_value', 'confidence': 0.1038}, 'conversation_summarization_suggestion': {}, 'annotation_id': 'annotation_id_value', 'create_time': {}, 'start_boundary': {}, 'end_boundary': {}, 'answer_feedback': {'correctness_level': 1, 'clicked': True, 'displayed': True}}], 'dialogflow_intents': {}, 'obfuscated_user_id': 'obfuscated_user_id_value'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.create_conversation(request) - - -def test_create_conversation_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.Conversation() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), - conversation_id='conversation_id_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.Conversation.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.create_conversation(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/conversations" % client.transport._host, args[1]) - - -def test_create_conversation_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_conversation( - contact_center_insights.CreateConversationRequest(), - parent='parent_value', - conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), - conversation_id='conversation_id_value', - ) - - -def test_create_conversation_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.UploadConversationRequest, - dict, -]) -def test_upload_conversation_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.upload_conversation(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_upload_conversation_rest_required_fields(request_type=contact_center_insights.UploadConversationRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).upload_conversation._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).upload_conversation._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.upload_conversation(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_upload_conversation_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.upload_conversation._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent", "conversation", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_upload_conversation_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_upload_conversation") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_upload_conversation") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.UploadConversationRequest.pb(contact_center_insights.UploadConversationRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = contact_center_insights.UploadConversationRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.upload_conversation(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_upload_conversation_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.UploadConversationRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.upload_conversation(request) - - -def test_upload_conversation_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.UpdateConversationRequest, - dict, -]) -def test_update_conversation_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'conversation': {'name': 'projects/sample1/locations/sample2/conversations/sample3'}} - request_init["conversation"] = {'call_metadata': {'customer_channel': 1706, 'agent_channel': 1351}, 'expire_time': {'seconds': 751, 'nanos': 543}, 'ttl': {'seconds': 751, 'nanos': 543}, 'name': 'projects/sample1/locations/sample2/conversations/sample3', 'data_source': {'gcs_source': {'audio_uri': 'audio_uri_value', 'transcript_uri': 'transcript_uri_value'}, 'dialogflow_source': {'dialogflow_conversation': 'dialogflow_conversation_value', 'audio_uri': 'audio_uri_value'}}, 'create_time': {}, 'update_time': {}, 'start_time': {}, 'language_code': 'language_code_value', 'agent_id': 'agent_id_value', 'labels': {}, 'transcript': {'transcript_segments': [{'message_time': {}, 'text': 'text_value', 'confidence': 0.1038, 'words': [{'start_offset': {}, 'end_offset': {}, 'word': 'word_value', 'confidence': 0.1038}], 'language_code': 'language_code_value', 'channel_tag': 1140, 'segment_participant': {'dialogflow_participant_name': 'dialogflow_participant_name_value', 'user_id': 'user_id_value', 'dialogflow_participant': 'dialogflow_participant_value', 'obfuscated_external_user_id': 'obfuscated_external_user_id_value', 'role': 1}, 'dialogflow_segment_metadata': {'smart_reply_allowlist_covered': True}, 'sentiment': {'magnitude': 0.9580000000000001, 'score': 0.54}}]}, 'medium': 1, 'duration': {}, 'turn_count': 1105, 'latest_analysis': {'name': 'name_value', 'request_time': {}, 'create_time': {}, 'analysis_result': {'call_analysis_metadata': {'annotations': [{'interruption_data': {}, 'sentiment_data': {}, 'silence_data': {}, 'hold_data': {}, 'entity_mention_data': {'entity_unique_id': 'entity_unique_id_value', 'type_': 1, 'sentiment': {}}, 'intent_match_data': {'intent_unique_id': 'intent_unique_id_value'}, 'phrase_match_data': {'phrase_matcher': 'phrase_matcher_value', 'display_name': 'display_name_value'}, 'issue_match_data': {'issue_assignment': {'issue': 'issue_value', 'score': 0.54, 'display_name': 'display_name_value'}}, 'channel_tag': 1140, 'annotation_start_boundary': {'word_index': 1075, 'transcript_index': 1729}, 'annotation_end_boundary': {}}], 'entities': {}, 'sentiments': [{'channel_tag': 1140, 'sentiment_data': {}}], 'intents': {}, 'phrase_matchers': {}, 'issue_model_result': {'issue_model': 'issue_model_value', 'issues': {}}}, 'end_time': {}}, 'annotator_selector': {'run_interruption_annotator': True, 'run_silence_annotator': True, 'run_phrase_matcher_annotator': True, 'phrase_matchers': ['phrase_matchers_value1', 'phrase_matchers_value2'], 'run_sentiment_annotator': True, 'run_entity_annotator': True, 'run_intent_annotator': True, 'run_issue_model_annotator': True, 'issue_models': ['issue_models_value1', 'issue_models_value2'], 'run_summarization_annotator': True, 'summarization_config': {'conversation_profile': 'conversation_profile_value', 'summarization_model': 1}}}, 'latest_summary': {'text': 'text_value', 'text_sections': {}, 'confidence': 0.1038, 'metadata': {}, 'answer_record': 'answer_record_value', 'conversation_model': 'conversation_model_value'}, 'runtime_annotations': [{'article_suggestion': {'title': 'title_value', 'uri': 'uri_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value', 'source': 'source_value'}, 'faq_answer': {'answer': 'answer_value', 'confidence_score': 0.1673, 'question': 'question_value', 'metadata': {}, 'query_record': 'query_record_value', 'source': 'source_value'}, 'smart_reply': {'reply': 'reply_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value'}, 'smart_compose_suggestion': {'suggestion': 'suggestion_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value'}, 'dialogflow_interaction': {'dialogflow_intent_id': 'dialogflow_intent_id_value', 'confidence': 0.1038}, 'conversation_summarization_suggestion': {}, 'annotation_id': 'annotation_id_value', 'create_time': {}, 'start_boundary': {}, 'end_boundary': {}, 'answer_feedback': {'correctness_level': 1, 'clicked': True, 'displayed': True}}], 'dialogflow_intents': {}, 'obfuscated_user_id': 'obfuscated_user_id_value'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.Conversation( - name='name_value', - language_code='language_code_value', - agent_id='agent_id_value', - medium=resources.Conversation.Medium.PHONE_CALL, - turn_count=1105, - obfuscated_user_id='obfuscated_user_id_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.Conversation.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_conversation(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Conversation) - assert response.name == 'name_value' - assert response.language_code == 'language_code_value' - assert response.agent_id == 'agent_id_value' - assert response.medium == resources.Conversation.Medium.PHONE_CALL - assert response.turn_count == 1105 - assert response.obfuscated_user_id == 'obfuscated_user_id_value' - - -def test_update_conversation_rest_required_fields(request_type=contact_center_insights.UpdateConversationRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_conversation._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_conversation._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.Conversation() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "patch", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = resources.Conversation.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.update_conversation(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_conversation_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_conversation._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("conversation", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_conversation_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_update_conversation") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_update_conversation") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.UpdateConversationRequest.pb(contact_center_insights.UpdateConversationRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = resources.Conversation.to_json(resources.Conversation()) - - request = contact_center_insights.UpdateConversationRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = resources.Conversation() - - client.update_conversation(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_conversation_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.UpdateConversationRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'conversation': {'name': 'projects/sample1/locations/sample2/conversations/sample3'}} - request_init["conversation"] = {'call_metadata': {'customer_channel': 1706, 'agent_channel': 1351}, 'expire_time': {'seconds': 751, 'nanos': 543}, 'ttl': {'seconds': 751, 'nanos': 543}, 'name': 'projects/sample1/locations/sample2/conversations/sample3', 'data_source': {'gcs_source': {'audio_uri': 'audio_uri_value', 'transcript_uri': 'transcript_uri_value'}, 'dialogflow_source': {'dialogflow_conversation': 'dialogflow_conversation_value', 'audio_uri': 'audio_uri_value'}}, 'create_time': {}, 'update_time': {}, 'start_time': {}, 'language_code': 'language_code_value', 'agent_id': 'agent_id_value', 'labels': {}, 'transcript': {'transcript_segments': [{'message_time': {}, 'text': 'text_value', 'confidence': 0.1038, 'words': [{'start_offset': {}, 'end_offset': {}, 'word': 'word_value', 'confidence': 0.1038}], 'language_code': 'language_code_value', 'channel_tag': 1140, 'segment_participant': {'dialogflow_participant_name': 'dialogflow_participant_name_value', 'user_id': 'user_id_value', 'dialogflow_participant': 'dialogflow_participant_value', 'obfuscated_external_user_id': 'obfuscated_external_user_id_value', 'role': 1}, 'dialogflow_segment_metadata': {'smart_reply_allowlist_covered': True}, 'sentiment': {'magnitude': 0.9580000000000001, 'score': 0.54}}]}, 'medium': 1, 'duration': {}, 'turn_count': 1105, 'latest_analysis': {'name': 'name_value', 'request_time': {}, 'create_time': {}, 'analysis_result': {'call_analysis_metadata': {'annotations': [{'interruption_data': {}, 'sentiment_data': {}, 'silence_data': {}, 'hold_data': {}, 'entity_mention_data': {'entity_unique_id': 'entity_unique_id_value', 'type_': 1, 'sentiment': {}}, 'intent_match_data': {'intent_unique_id': 'intent_unique_id_value'}, 'phrase_match_data': {'phrase_matcher': 'phrase_matcher_value', 'display_name': 'display_name_value'}, 'issue_match_data': {'issue_assignment': {'issue': 'issue_value', 'score': 0.54, 'display_name': 'display_name_value'}}, 'channel_tag': 1140, 'annotation_start_boundary': {'word_index': 1075, 'transcript_index': 1729}, 'annotation_end_boundary': {}}], 'entities': {}, 'sentiments': [{'channel_tag': 1140, 'sentiment_data': {}}], 'intents': {}, 'phrase_matchers': {}, 'issue_model_result': {'issue_model': 'issue_model_value', 'issues': {}}}, 'end_time': {}}, 'annotator_selector': {'run_interruption_annotator': True, 'run_silence_annotator': True, 'run_phrase_matcher_annotator': True, 'phrase_matchers': ['phrase_matchers_value1', 'phrase_matchers_value2'], 'run_sentiment_annotator': True, 'run_entity_annotator': True, 'run_intent_annotator': True, 'run_issue_model_annotator': True, 'issue_models': ['issue_models_value1', 'issue_models_value2'], 'run_summarization_annotator': True, 'summarization_config': {'conversation_profile': 'conversation_profile_value', 'summarization_model': 1}}}, 'latest_summary': {'text': 'text_value', 'text_sections': {}, 'confidence': 0.1038, 'metadata': {}, 'answer_record': 'answer_record_value', 'conversation_model': 'conversation_model_value'}, 'runtime_annotations': [{'article_suggestion': {'title': 'title_value', 'uri': 'uri_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value', 'source': 'source_value'}, 'faq_answer': {'answer': 'answer_value', 'confidence_score': 0.1673, 'question': 'question_value', 'metadata': {}, 'query_record': 'query_record_value', 'source': 'source_value'}, 'smart_reply': {'reply': 'reply_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value'}, 'smart_compose_suggestion': {'suggestion': 'suggestion_value', 'confidence_score': 0.1673, 'metadata': {}, 'query_record': 'query_record_value'}, 'dialogflow_interaction': {'dialogflow_intent_id': 'dialogflow_intent_id_value', 'confidence': 0.1038}, 'conversation_summarization_suggestion': {}, 'annotation_id': 'annotation_id_value', 'create_time': {}, 'start_boundary': {}, 'end_boundary': {}, 'answer_feedback': {'correctness_level': 1, 'clicked': True, 'displayed': True}}], 'dialogflow_intents': {}, 'obfuscated_user_id': 'obfuscated_user_id_value'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.update_conversation(request) - - -def test_update_conversation_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.Conversation() - - # get arguments that satisfy an http rule for this method - sample_request = {'conversation': {'name': 'projects/sample1/locations/sample2/conversations/sample3'}} - - # get truthy value for each flattened field - mock_args = dict( - conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.Conversation.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_conversation(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{conversation.name=projects/*/locations/*/conversations/*}" % client.transport._host, args[1]) - - -def test_update_conversation_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_conversation( - contact_center_insights.UpdateConversationRequest(), - conversation=resources.Conversation(call_metadata=resources.Conversation.CallMetadata(customer_channel=1706)), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_update_conversation_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.GetConversationRequest, - dict, -]) -def test_get_conversation_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/conversations/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.Conversation( - name='name_value', - language_code='language_code_value', - agent_id='agent_id_value', - medium=resources.Conversation.Medium.PHONE_CALL, - turn_count=1105, - obfuscated_user_id='obfuscated_user_id_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.Conversation.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_conversation(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Conversation) - assert response.name == 'name_value' - assert response.language_code == 'language_code_value' - assert response.agent_id == 'agent_id_value' - assert response.medium == resources.Conversation.Medium.PHONE_CALL - assert response.turn_count == 1105 - assert response.obfuscated_user_id == 'obfuscated_user_id_value' - - -def test_get_conversation_rest_required_fields(request_type=contact_center_insights.GetConversationRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_conversation._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_conversation._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("view", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.Conversation() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = resources.Conversation.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_conversation(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_conversation_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_conversation._get_unset_required_fields({}) - assert set(unset_fields) == (set(("view", )) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_conversation_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_get_conversation") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_get_conversation") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.GetConversationRequest.pb(contact_center_insights.GetConversationRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = resources.Conversation.to_json(resources.Conversation()) - - request = contact_center_insights.GetConversationRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = resources.Conversation() - - client.get_conversation(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_conversation_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.GetConversationRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/conversations/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_conversation(request) - - -def test_get_conversation_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.Conversation() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/conversations/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.Conversation.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_conversation(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/conversations/*}" % client.transport._host, args[1]) - - -def test_get_conversation_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_conversation( - contact_center_insights.GetConversationRequest(), - name='name_value', - ) - - -def test_get_conversation_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.ListConversationsRequest, - dict, -]) -def test_list_conversations_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListConversationsResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = contact_center_insights.ListConversationsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_conversations(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListConversationsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_conversations_rest_required_fields(request_type=contact_center_insights.ListConversationsRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_conversations._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_conversations._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("filter", "page_size", "page_token", "view", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListConversationsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = contact_center_insights.ListConversationsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_conversations(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_conversations_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_conversations._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "pageSize", "pageToken", "view", )) & set(("parent", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_conversations_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_list_conversations") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_list_conversations") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.ListConversationsRequest.pb(contact_center_insights.ListConversationsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = contact_center_insights.ListConversationsResponse.to_json(contact_center_insights.ListConversationsResponse()) - - request = contact_center_insights.ListConversationsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = contact_center_insights.ListConversationsResponse() - - client.list_conversations(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_conversations_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.ListConversationsRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_conversations(request) - - -def test_list_conversations_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListConversationsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = contact_center_insights.ListConversationsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_conversations(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/conversations" % client.transport._host, args[1]) - - -def test_list_conversations_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_conversations( - contact_center_insights.ListConversationsRequest(), - parent='parent_value', - ) - - -def test_list_conversations_rest_pager(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - contact_center_insights.ListConversationsResponse( - conversations=[ - resources.Conversation(), - resources.Conversation(), - resources.Conversation(), - ], - next_page_token='abc', - ), - contact_center_insights.ListConversationsResponse( - conversations=[], - next_page_token='def', - ), - contact_center_insights.ListConversationsResponse( - conversations=[ - resources.Conversation(), - ], - next_page_token='ghi', - ), - contact_center_insights.ListConversationsResponse( - conversations=[ - resources.Conversation(), - resources.Conversation(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(contact_center_insights.ListConversationsResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - pager = client.list_conversations(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.Conversation) - for i in results) - - pages = list(client.list_conversations(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.DeleteConversationRequest, - dict, -]) -def test_delete_conversation_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/conversations/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_conversation(request) - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_conversation_rest_required_fields(request_type=contact_center_insights.DeleteConversationRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_conversation._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_conversation._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("force", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = None - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.delete_conversation(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_conversation_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_conversation._get_unset_required_fields({}) - assert set(unset_fields) == (set(("force", )) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_conversation_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_delete_conversation") as pre: - pre.assert_not_called() - pb_message = contact_center_insights.DeleteConversationRequest.pb(contact_center_insights.DeleteConversationRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - - request = contact_center_insights.DeleteConversationRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - - client.delete_conversation(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - - -def test_delete_conversation_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.DeleteConversationRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/conversations/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.delete_conversation(request) - - -def test_delete_conversation_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/conversations/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_conversation(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/conversations/*}" % client.transport._host, args[1]) - - -def test_delete_conversation_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_conversation( - contact_center_insights.DeleteConversationRequest(), - name='name_value', - ) - - -def test_delete_conversation_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.CreateAnalysisRequest, - dict, -]) -def test_create_analysis_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/conversations/sample3'} - request_init["analysis"] = {'name': 'name_value', 'request_time': {'seconds': 751, 'nanos': 543}, 'create_time': {}, 'analysis_result': {'call_analysis_metadata': {'annotations': [{'interruption_data': {}, 'sentiment_data': {'magnitude': 0.9580000000000001, 'score': 0.54}, 'silence_data': {}, 'hold_data': {}, 'entity_mention_data': {'entity_unique_id': 'entity_unique_id_value', 'type_': 1, 'sentiment': {}}, 'intent_match_data': {'intent_unique_id': 'intent_unique_id_value'}, 'phrase_match_data': {'phrase_matcher': 'phrase_matcher_value', 'display_name': 'display_name_value'}, 'issue_match_data': {'issue_assignment': {'issue': 'issue_value', 'score': 0.54, 'display_name': 'display_name_value'}}, 'channel_tag': 1140, 'annotation_start_boundary': {'word_index': 1075, 'transcript_index': 1729}, 'annotation_end_boundary': {}}], 'entities': {}, 'sentiments': [{'channel_tag': 1140, 'sentiment_data': {}}], 'intents': {}, 'phrase_matchers': {}, 'issue_model_result': {'issue_model': 'issue_model_value', 'issues': {}}}, 'end_time': {}}, 'annotator_selector': {'run_interruption_annotator': True, 'run_silence_annotator': True, 'run_phrase_matcher_annotator': True, 'phrase_matchers': ['phrase_matchers_value1', 'phrase_matchers_value2'], 'run_sentiment_annotator': True, 'run_entity_annotator': True, 'run_intent_annotator': True, 'run_issue_model_annotator': True, 'issue_models': ['issue_models_value1', 'issue_models_value2'], 'run_summarization_annotator': True, 'summarization_config': {'conversation_profile': 'conversation_profile_value', 'summarization_model': 1}}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.create_analysis(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_create_analysis_rest_required_fields(request_type=contact_center_insights.CreateAnalysisRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_analysis._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_analysis._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.create_analysis(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_analysis_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_analysis._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent", "analysis", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_analysis_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_create_analysis") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_create_analysis") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.CreateAnalysisRequest.pb(contact_center_insights.CreateAnalysisRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = contact_center_insights.CreateAnalysisRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.create_analysis(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_create_analysis_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.CreateAnalysisRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/conversations/sample3'} - request_init["analysis"] = {'name': 'name_value', 'request_time': {'seconds': 751, 'nanos': 543}, 'create_time': {}, 'analysis_result': {'call_analysis_metadata': {'annotations': [{'interruption_data': {}, 'sentiment_data': {'magnitude': 0.9580000000000001, 'score': 0.54}, 'silence_data': {}, 'hold_data': {}, 'entity_mention_data': {'entity_unique_id': 'entity_unique_id_value', 'type_': 1, 'sentiment': {}}, 'intent_match_data': {'intent_unique_id': 'intent_unique_id_value'}, 'phrase_match_data': {'phrase_matcher': 'phrase_matcher_value', 'display_name': 'display_name_value'}, 'issue_match_data': {'issue_assignment': {'issue': 'issue_value', 'score': 0.54, 'display_name': 'display_name_value'}}, 'channel_tag': 1140, 'annotation_start_boundary': {'word_index': 1075, 'transcript_index': 1729}, 'annotation_end_boundary': {}}], 'entities': {}, 'sentiments': [{'channel_tag': 1140, 'sentiment_data': {}}], 'intents': {}, 'phrase_matchers': {}, 'issue_model_result': {'issue_model': 'issue_model_value', 'issues': {}}}, 'end_time': {}}, 'annotator_selector': {'run_interruption_annotator': True, 'run_silence_annotator': True, 'run_phrase_matcher_annotator': True, 'phrase_matchers': ['phrase_matchers_value1', 'phrase_matchers_value2'], 'run_sentiment_annotator': True, 'run_entity_annotator': True, 'run_intent_annotator': True, 'run_issue_model_annotator': True, 'issue_models': ['issue_models_value1', 'issue_models_value2'], 'run_summarization_annotator': True, 'summarization_config': {'conversation_profile': 'conversation_profile_value', 'summarization_model': 1}}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.create_analysis(request) - - -def test_create_analysis_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/conversations/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - analysis=resources.Analysis(name='name_value'), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.create_analysis(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/conversations/*}/analyses" % client.transport._host, args[1]) - - -def test_create_analysis_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_analysis( - contact_center_insights.CreateAnalysisRequest(), - parent='parent_value', - analysis=resources.Analysis(name='name_value'), - ) - - -def test_create_analysis_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.GetAnalysisRequest, - dict, -]) -def test_get_analysis_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/conversations/sample3/analyses/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.Analysis( - name='name_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.Analysis.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_analysis(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Analysis) - assert response.name == 'name_value' - - -def test_get_analysis_rest_required_fields(request_type=contact_center_insights.GetAnalysisRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_analysis._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_analysis._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.Analysis() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = resources.Analysis.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_analysis(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_analysis_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_analysis._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_analysis_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_get_analysis") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_get_analysis") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.GetAnalysisRequest.pb(contact_center_insights.GetAnalysisRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = resources.Analysis.to_json(resources.Analysis()) - - request = contact_center_insights.GetAnalysisRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = resources.Analysis() - - client.get_analysis(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_analysis_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.GetAnalysisRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/conversations/sample3/analyses/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_analysis(request) - - -def test_get_analysis_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.Analysis() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/conversations/sample3/analyses/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.Analysis.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_analysis(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/conversations/*/analyses/*}" % client.transport._host, args[1]) - - -def test_get_analysis_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_analysis( - contact_center_insights.GetAnalysisRequest(), - name='name_value', - ) - - -def test_get_analysis_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.ListAnalysesRequest, - dict, -]) -def test_list_analyses_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/conversations/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListAnalysesResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = contact_center_insights.ListAnalysesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_analyses(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListAnalysesPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_analyses_rest_required_fields(request_type=contact_center_insights.ListAnalysesRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_analyses._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_analyses._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("filter", "page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListAnalysesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = contact_center_insights.ListAnalysesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_analyses(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_analyses_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_analyses._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "pageSize", "pageToken", )) & set(("parent", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_analyses_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_list_analyses") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_list_analyses") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.ListAnalysesRequest.pb(contact_center_insights.ListAnalysesRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = contact_center_insights.ListAnalysesResponse.to_json(contact_center_insights.ListAnalysesResponse()) - - request = contact_center_insights.ListAnalysesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = contact_center_insights.ListAnalysesResponse() - - client.list_analyses(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_analyses_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.ListAnalysesRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/conversations/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_analyses(request) - - -def test_list_analyses_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListAnalysesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/conversations/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = contact_center_insights.ListAnalysesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_analyses(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/conversations/*}/analyses" % client.transport._host, args[1]) - - -def test_list_analyses_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_analyses( - contact_center_insights.ListAnalysesRequest(), - parent='parent_value', - ) - - -def test_list_analyses_rest_pager(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - contact_center_insights.ListAnalysesResponse( - analyses=[ - resources.Analysis(), - resources.Analysis(), - resources.Analysis(), - ], - next_page_token='abc', - ), - contact_center_insights.ListAnalysesResponse( - analyses=[], - next_page_token='def', - ), - contact_center_insights.ListAnalysesResponse( - analyses=[ - resources.Analysis(), - ], - next_page_token='ghi', - ), - contact_center_insights.ListAnalysesResponse( - analyses=[ - resources.Analysis(), - resources.Analysis(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(contact_center_insights.ListAnalysesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2/conversations/sample3'} - - pager = client.list_analyses(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.Analysis) - for i in results) - - pages = list(client.list_analyses(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.DeleteAnalysisRequest, - dict, -]) -def test_delete_analysis_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/conversations/sample3/analyses/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_analysis(request) - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_analysis_rest_required_fields(request_type=contact_center_insights.DeleteAnalysisRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_analysis._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_analysis._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = None - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.delete_analysis(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_analysis_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_analysis._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_analysis_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_delete_analysis") as pre: - pre.assert_not_called() - pb_message = contact_center_insights.DeleteAnalysisRequest.pb(contact_center_insights.DeleteAnalysisRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - - request = contact_center_insights.DeleteAnalysisRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - - client.delete_analysis(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - - -def test_delete_analysis_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.DeleteAnalysisRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/conversations/sample3/analyses/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.delete_analysis(request) - - -def test_delete_analysis_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/conversations/sample3/analyses/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_analysis(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/conversations/*/analyses/*}" % client.transport._host, args[1]) - - -def test_delete_analysis_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_analysis( - contact_center_insights.DeleteAnalysisRequest(), - name='name_value', - ) - - -def test_delete_analysis_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.BulkAnalyzeConversationsRequest, - dict, -]) -def test_bulk_analyze_conversations_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.bulk_analyze_conversations(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_bulk_analyze_conversations_rest_required_fields(request_type=contact_center_insights.BulkAnalyzeConversationsRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["filter"] = "" - request_init["analysis_percentage"] = 0.0 - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).bulk_analyze_conversations._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - jsonified_request["filter"] = 'filter_value' - jsonified_request["analysisPercentage"] = 0.20170000000000002 - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).bulk_analyze_conversations._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - assert "filter" in jsonified_request - assert jsonified_request["filter"] == 'filter_value' - assert "analysisPercentage" in jsonified_request - assert jsonified_request["analysisPercentage"] == 0.20170000000000002 - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.bulk_analyze_conversations(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_bulk_analyze_conversations_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.bulk_analyze_conversations._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent", "filter", "analysisPercentage", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_bulk_analyze_conversations_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_bulk_analyze_conversations") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_bulk_analyze_conversations") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.BulkAnalyzeConversationsRequest.pb(contact_center_insights.BulkAnalyzeConversationsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = contact_center_insights.BulkAnalyzeConversationsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.bulk_analyze_conversations(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_bulk_analyze_conversations_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.BulkAnalyzeConversationsRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.bulk_analyze_conversations(request) - - -def test_bulk_analyze_conversations_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - filter='filter_value', - analysis_percentage=0.20170000000000002, - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.bulk_analyze_conversations(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/conversations:bulkAnalyze" % client.transport._host, args[1]) - - -def test_bulk_analyze_conversations_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.bulk_analyze_conversations( - contact_center_insights.BulkAnalyzeConversationsRequest(), - parent='parent_value', - filter='filter_value', - analysis_percentage=0.20170000000000002, - ) - - -def test_bulk_analyze_conversations_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.IngestConversationsRequest, - dict, -]) -def test_ingest_conversations_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.ingest_conversations(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_ingest_conversations_rest_required_fields(request_type=contact_center_insights.IngestConversationsRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).ingest_conversations._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).ingest_conversations._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.ingest_conversations(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_ingest_conversations_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.ingest_conversations._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_ingest_conversations_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_ingest_conversations") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_ingest_conversations") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.IngestConversationsRequest.pb(contact_center_insights.IngestConversationsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = contact_center_insights.IngestConversationsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.ingest_conversations(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_ingest_conversations_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.IngestConversationsRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.ingest_conversations(request) - - -def test_ingest_conversations_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.ingest_conversations(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/conversations:ingest" % client.transport._host, args[1]) - - -def test_ingest_conversations_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.ingest_conversations( - contact_center_insights.IngestConversationsRequest(), - parent='parent_value', - ) - - -def test_ingest_conversations_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.ExportInsightsDataRequest, - dict, -]) -def test_export_insights_data_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.export_insights_data(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_export_insights_data_rest_required_fields(request_type=contact_center_insights.ExportInsightsDataRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).export_insights_data._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).export_insights_data._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.export_insights_data(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_export_insights_data_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.export_insights_data._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_export_insights_data_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_export_insights_data") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_export_insights_data") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.ExportInsightsDataRequest.pb(contact_center_insights.ExportInsightsDataRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = contact_center_insights.ExportInsightsDataRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.export_insights_data(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_export_insights_data_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.ExportInsightsDataRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.export_insights_data(request) - - -def test_export_insights_data_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.export_insights_data(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/insightsdata:export" % client.transport._host, args[1]) - - -def test_export_insights_data_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.export_insights_data( - contact_center_insights.ExportInsightsDataRequest(), - parent='parent_value', - ) - - -def test_export_insights_data_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.CreateIssueModelRequest, - dict, -]) -def test_create_issue_model_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["issue_model"] = {'name': 'name_value', 'display_name': 'display_name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'issue_count': 1201, 'state': 1, 'input_data_config': {'medium': 1, 'training_conversations_count': 3025, 'filter': 'filter_value'}, 'training_stats': {'analyzed_conversations_count': 3021, 'unclassified_conversations_count': 3439, 'issue_stats': {}}, 'model_type': 1, 'language_code': 'language_code_value'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.create_issue_model(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_create_issue_model_rest_required_fields(request_type=contact_center_insights.CreateIssueModelRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.create_issue_model(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_issue_model_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_issue_model._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent", "issueModel", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_issue_model_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_create_issue_model") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_create_issue_model") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.CreateIssueModelRequest.pb(contact_center_insights.CreateIssueModelRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = contact_center_insights.CreateIssueModelRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.create_issue_model(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_create_issue_model_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.CreateIssueModelRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["issue_model"] = {'name': 'name_value', 'display_name': 'display_name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'issue_count': 1201, 'state': 1, 'input_data_config': {'medium': 1, 'training_conversations_count': 3025, 'filter': 'filter_value'}, 'training_stats': {'analyzed_conversations_count': 3021, 'unclassified_conversations_count': 3439, 'issue_stats': {}}, 'model_type': 1, 'language_code': 'language_code_value'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.create_issue_model(request) - - -def test_create_issue_model_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - issue_model=resources.IssueModel(name='name_value'), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.create_issue_model(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/issueModels" % client.transport._host, args[1]) - - -def test_create_issue_model_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_issue_model( - contact_center_insights.CreateIssueModelRequest(), - parent='parent_value', - issue_model=resources.IssueModel(name='name_value'), - ) - - -def test_create_issue_model_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.UpdateIssueModelRequest, - dict, -]) -def test_update_issue_model_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'issue_model': {'name': 'projects/sample1/locations/sample2/issueModels/sample3'}} - request_init["issue_model"] = {'name': 'projects/sample1/locations/sample2/issueModels/sample3', 'display_name': 'display_name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'issue_count': 1201, 'state': 1, 'input_data_config': {'medium': 1, 'training_conversations_count': 3025, 'filter': 'filter_value'}, 'training_stats': {'analyzed_conversations_count': 3021, 'unclassified_conversations_count': 3439, 'issue_stats': {}}, 'model_type': 1, 'language_code': 'language_code_value'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.IssueModel( - name='name_value', - display_name='display_name_value', - issue_count=1201, - state=resources.IssueModel.State.UNDEPLOYED, - model_type=resources.IssueModel.ModelType.TYPE_V1, - language_code='language_code_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.IssueModel.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_issue_model(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.IssueModel) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.issue_count == 1201 - assert response.state == resources.IssueModel.State.UNDEPLOYED - assert response.model_type == resources.IssueModel.ModelType.TYPE_V1 - assert response.language_code == 'language_code_value' - - -def test_update_issue_model_rest_required_fields(request_type=contact_center_insights.UpdateIssueModelRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_issue_model._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.IssueModel() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "patch", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = resources.IssueModel.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.update_issue_model(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_issue_model_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_issue_model._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("issueModel", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_issue_model_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_update_issue_model") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_update_issue_model") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.UpdateIssueModelRequest.pb(contact_center_insights.UpdateIssueModelRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = resources.IssueModel.to_json(resources.IssueModel()) - - request = contact_center_insights.UpdateIssueModelRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = resources.IssueModel() - - client.update_issue_model(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_issue_model_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.UpdateIssueModelRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'issue_model': {'name': 'projects/sample1/locations/sample2/issueModels/sample3'}} - request_init["issue_model"] = {'name': 'projects/sample1/locations/sample2/issueModels/sample3', 'display_name': 'display_name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'issue_count': 1201, 'state': 1, 'input_data_config': {'medium': 1, 'training_conversations_count': 3025, 'filter': 'filter_value'}, 'training_stats': {'analyzed_conversations_count': 3021, 'unclassified_conversations_count': 3439, 'issue_stats': {}}, 'model_type': 1, 'language_code': 'language_code_value'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.update_issue_model(request) - - -def test_update_issue_model_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.IssueModel() - - # get arguments that satisfy an http rule for this method - sample_request = {'issue_model': {'name': 'projects/sample1/locations/sample2/issueModels/sample3'}} - - # get truthy value for each flattened field - mock_args = dict( - issue_model=resources.IssueModel(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.IssueModel.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_issue_model(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{issue_model.name=projects/*/locations/*/issueModels/*}" % client.transport._host, args[1]) - - -def test_update_issue_model_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_issue_model( - contact_center_insights.UpdateIssueModelRequest(), - issue_model=resources.IssueModel(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_update_issue_model_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.GetIssueModelRequest, - dict, -]) -def test_get_issue_model_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.IssueModel( - name='name_value', - display_name='display_name_value', - issue_count=1201, - state=resources.IssueModel.State.UNDEPLOYED, - model_type=resources.IssueModel.ModelType.TYPE_V1, - language_code='language_code_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.IssueModel.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_issue_model(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.IssueModel) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.issue_count == 1201 - assert response.state == resources.IssueModel.State.UNDEPLOYED - assert response.model_type == resources.IssueModel.ModelType.TYPE_V1 - assert response.language_code == 'language_code_value' - - -def test_get_issue_model_rest_required_fields(request_type=contact_center_insights.GetIssueModelRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.IssueModel() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = resources.IssueModel.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_issue_model(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_issue_model_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_issue_model._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_issue_model_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_get_issue_model") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_get_issue_model") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.GetIssueModelRequest.pb(contact_center_insights.GetIssueModelRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = resources.IssueModel.to_json(resources.IssueModel()) - - request = contact_center_insights.GetIssueModelRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = resources.IssueModel() - - client.get_issue_model(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_issue_model_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.GetIssueModelRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_issue_model(request) - - -def test_get_issue_model_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.IssueModel() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.IssueModel.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_issue_model(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/issueModels/*}" % client.transport._host, args[1]) - - -def test_get_issue_model_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_issue_model( - contact_center_insights.GetIssueModelRequest(), - name='name_value', - ) - - -def test_get_issue_model_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.ListIssueModelsRequest, - dict, -]) -def test_list_issue_models_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListIssueModelsResponse( - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = contact_center_insights.ListIssueModelsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_issue_models(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, contact_center_insights.ListIssueModelsResponse) - - -def test_list_issue_models_rest_required_fields(request_type=contact_center_insights.ListIssueModelsRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_issue_models._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_issue_models._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListIssueModelsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = contact_center_insights.ListIssueModelsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_issue_models(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_issue_models_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_issue_models._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_issue_models_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_list_issue_models") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_list_issue_models") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.ListIssueModelsRequest.pb(contact_center_insights.ListIssueModelsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = contact_center_insights.ListIssueModelsResponse.to_json(contact_center_insights.ListIssueModelsResponse()) - - request = contact_center_insights.ListIssueModelsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = contact_center_insights.ListIssueModelsResponse() - - client.list_issue_models(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_issue_models_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.ListIssueModelsRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_issue_models(request) - - -def test_list_issue_models_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListIssueModelsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = contact_center_insights.ListIssueModelsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_issue_models(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/issueModels" % client.transport._host, args[1]) - - -def test_list_issue_models_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_issue_models( - contact_center_insights.ListIssueModelsRequest(), - parent='parent_value', - ) - - -def test_list_issue_models_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.DeleteIssueModelRequest, - dict, -]) -def test_delete_issue_model_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_issue_model(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_delete_issue_model_rest_required_fields(request_type=contact_center_insights.DeleteIssueModelRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.delete_issue_model(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_issue_model_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_issue_model._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_issue_model_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_delete_issue_model") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_delete_issue_model") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.DeleteIssueModelRequest.pb(contact_center_insights.DeleteIssueModelRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = contact_center_insights.DeleteIssueModelRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.delete_issue_model(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_delete_issue_model_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.DeleteIssueModelRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.delete_issue_model(request) - - -def test_delete_issue_model_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_issue_model(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/issueModels/*}" % client.transport._host, args[1]) - - -def test_delete_issue_model_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_issue_model( - contact_center_insights.DeleteIssueModelRequest(), - name='name_value', - ) - - -def test_delete_issue_model_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.DeployIssueModelRequest, - dict, -]) -def test_deploy_issue_model_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.deploy_issue_model(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_deploy_issue_model_rest_required_fields(request_type=contact_center_insights.DeployIssueModelRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).deploy_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).deploy_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.deploy_issue_model(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_deploy_issue_model_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.deploy_issue_model._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_deploy_issue_model_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_deploy_issue_model") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_deploy_issue_model") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.DeployIssueModelRequest.pb(contact_center_insights.DeployIssueModelRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = contact_center_insights.DeployIssueModelRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.deploy_issue_model(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_deploy_issue_model_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.DeployIssueModelRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.deploy_issue_model(request) - - -def test_deploy_issue_model_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.deploy_issue_model(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/issueModels/*}:deploy" % client.transport._host, args[1]) - - -def test_deploy_issue_model_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.deploy_issue_model( - contact_center_insights.DeployIssueModelRequest(), - name='name_value', - ) - - -def test_deploy_issue_model_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.UndeployIssueModelRequest, - dict, -]) -def test_undeploy_issue_model_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.undeploy_issue_model(request) - - # Establish that the response is the type that we expect. - assert response.operation.name == "operations/spam" - - -def test_undeploy_issue_model_rest_required_fields(request_type=contact_center_insights.UndeployIssueModelRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).undeploy_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).undeploy_issue_model._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.undeploy_issue_model(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_undeploy_issue_model_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.undeploy_issue_model._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_undeploy_issue_model_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_undeploy_issue_model") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_undeploy_issue_model") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.UndeployIssueModelRequest.pb(contact_center_insights.UndeployIssueModelRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = json_format.MessageToJson(operations_pb2.Operation()) - - request = contact_center_insights.UndeployIssueModelRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.undeploy_issue_model(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_undeploy_issue_model_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.UndeployIssueModelRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.undeploy_issue_model(request) - - -def test_undeploy_issue_model_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/issueModels/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.undeploy_issue_model(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/issueModels/*}:undeploy" % client.transport._host, args[1]) - - -def test_undeploy_issue_model_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.undeploy_issue_model( - contact_center_insights.UndeployIssueModelRequest(), - name='name_value', - ) - - -def test_undeploy_issue_model_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.GetIssueRequest, - dict, -]) -def test_get_issue_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.Issue( - name='name_value', - display_name='display_name_value', - sample_utterances=['sample_utterances_value'], - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.Issue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_issue(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Issue) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.sample_utterances == ['sample_utterances_value'] - - -def test_get_issue_rest_required_fields(request_type=contact_center_insights.GetIssueRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_issue._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_issue._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.Issue() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = resources.Issue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_issue(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_issue_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_issue._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_issue_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_get_issue") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_get_issue") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.GetIssueRequest.pb(contact_center_insights.GetIssueRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = resources.Issue.to_json(resources.Issue()) - - request = contact_center_insights.GetIssueRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = resources.Issue() - - client.get_issue(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_issue_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.GetIssueRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_issue(request) - - -def test_get_issue_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.Issue() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.Issue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_issue(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/issueModels/*/issues/*}" % client.transport._host, args[1]) - - -def test_get_issue_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_issue( - contact_center_insights.GetIssueRequest(), - name='name_value', - ) - - -def test_get_issue_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.ListIssuesRequest, - dict, -]) -def test_list_issues_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/issueModels/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListIssuesResponse( - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = contact_center_insights.ListIssuesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_issues(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, contact_center_insights.ListIssuesResponse) - - -def test_list_issues_rest_required_fields(request_type=contact_center_insights.ListIssuesRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_issues._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_issues._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListIssuesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = contact_center_insights.ListIssuesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_issues(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_issues_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_issues._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_issues_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_list_issues") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_list_issues") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.ListIssuesRequest.pb(contact_center_insights.ListIssuesRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = contact_center_insights.ListIssuesResponse.to_json(contact_center_insights.ListIssuesResponse()) - - request = contact_center_insights.ListIssuesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = contact_center_insights.ListIssuesResponse() - - client.list_issues(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_issues_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.ListIssuesRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/issueModels/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_issues(request) - - -def test_list_issues_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListIssuesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/issueModels/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = contact_center_insights.ListIssuesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_issues(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/issueModels/*}/issues" % client.transport._host, args[1]) - - -def test_list_issues_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_issues( - contact_center_insights.ListIssuesRequest(), - parent='parent_value', - ) - - -def test_list_issues_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.UpdateIssueRequest, - dict, -]) -def test_update_issue_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'issue': {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4'}} - request_init["issue"] = {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4', 'display_name': 'display_name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'sample_utterances': ['sample_utterances_value1', 'sample_utterances_value2']} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.Issue( - name='name_value', - display_name='display_name_value', - sample_utterances=['sample_utterances_value'], - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.Issue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_issue(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Issue) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.sample_utterances == ['sample_utterances_value'] - - -def test_update_issue_rest_required_fields(request_type=contact_center_insights.UpdateIssueRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_issue._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_issue._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.Issue() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "patch", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = resources.Issue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.update_issue(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_issue_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_issue._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("issue", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_issue_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_update_issue") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_update_issue") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.UpdateIssueRequest.pb(contact_center_insights.UpdateIssueRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = resources.Issue.to_json(resources.Issue()) - - request = contact_center_insights.UpdateIssueRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = resources.Issue() - - client.update_issue(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_issue_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.UpdateIssueRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'issue': {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4'}} - request_init["issue"] = {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4', 'display_name': 'display_name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'sample_utterances': ['sample_utterances_value1', 'sample_utterances_value2']} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.update_issue(request) - - -def test_update_issue_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.Issue() - - # get arguments that satisfy an http rule for this method - sample_request = {'issue': {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4'}} - - # get truthy value for each flattened field - mock_args = dict( - issue=resources.Issue(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.Issue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_issue(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{issue.name=projects/*/locations/*/issueModels/*/issues/*}" % client.transport._host, args[1]) - - -def test_update_issue_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_issue( - contact_center_insights.UpdateIssueRequest(), - issue=resources.Issue(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_update_issue_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.DeleteIssueRequest, - dict, -]) -def test_delete_issue_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_issue(request) - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_issue_rest_required_fields(request_type=contact_center_insights.DeleteIssueRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_issue._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_issue._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = None - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.delete_issue(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_issue_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_issue._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_issue_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_delete_issue") as pre: - pre.assert_not_called() - pb_message = contact_center_insights.DeleteIssueRequest.pb(contact_center_insights.DeleteIssueRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - - request = contact_center_insights.DeleteIssueRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - - client.delete_issue(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - - -def test_delete_issue_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.DeleteIssueRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.delete_issue(request) - - -def test_delete_issue_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/issueModels/sample3/issues/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_issue(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/issueModels/*/issues/*}" % client.transport._host, args[1]) - - -def test_delete_issue_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_issue( - contact_center_insights.DeleteIssueRequest(), - name='name_value', - ) - - -def test_delete_issue_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.CalculateIssueModelStatsRequest, - dict, -]) -def test_calculate_issue_model_stats_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'issue_model': 'projects/sample1/locations/sample2/issueModels/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.CalculateIssueModelStatsResponse( - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = contact_center_insights.CalculateIssueModelStatsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.calculate_issue_model_stats(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, contact_center_insights.CalculateIssueModelStatsResponse) - - -def test_calculate_issue_model_stats_rest_required_fields(request_type=contact_center_insights.CalculateIssueModelStatsRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["issue_model"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).calculate_issue_model_stats._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["issueModel"] = 'issue_model_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).calculate_issue_model_stats._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "issueModel" in jsonified_request - assert jsonified_request["issueModel"] == 'issue_model_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.CalculateIssueModelStatsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = contact_center_insights.CalculateIssueModelStatsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.calculate_issue_model_stats(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_calculate_issue_model_stats_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.calculate_issue_model_stats._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("issueModel", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_calculate_issue_model_stats_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_calculate_issue_model_stats") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_calculate_issue_model_stats") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.CalculateIssueModelStatsRequest.pb(contact_center_insights.CalculateIssueModelStatsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = contact_center_insights.CalculateIssueModelStatsResponse.to_json(contact_center_insights.CalculateIssueModelStatsResponse()) - - request = contact_center_insights.CalculateIssueModelStatsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = contact_center_insights.CalculateIssueModelStatsResponse() - - client.calculate_issue_model_stats(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_calculate_issue_model_stats_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.CalculateIssueModelStatsRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'issue_model': 'projects/sample1/locations/sample2/issueModels/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.calculate_issue_model_stats(request) - - -def test_calculate_issue_model_stats_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.CalculateIssueModelStatsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'issue_model': 'projects/sample1/locations/sample2/issueModels/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - issue_model='issue_model_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = contact_center_insights.CalculateIssueModelStatsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.calculate_issue_model_stats(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{issue_model=projects/*/locations/*/issueModels/*}:calculateIssueModelStats" % client.transport._host, args[1]) - - -def test_calculate_issue_model_stats_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.calculate_issue_model_stats( - contact_center_insights.CalculateIssueModelStatsRequest(), - issue_model='issue_model_value', - ) - - -def test_calculate_issue_model_stats_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.CreatePhraseMatcherRequest, - dict, -]) -def test_create_phrase_matcher_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["phrase_matcher"] = {'name': 'name_value', 'revision_id': 'revision_id_value', 'version_tag': 'version_tag_value', 'revision_create_time': {'seconds': 751, 'nanos': 543}, 'display_name': 'display_name_value', 'type_': 1, 'active': True, 'phrase_match_rule_groups': [{'type_': 1, 'phrase_match_rules': [{'query': 'query_value', 'negated': True, 'config': {'exact_match_config': {'case_sensitive': True}}}]}], 'activation_update_time': {}, 'role_match': 1, 'update_time': {}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.PhraseMatcher( - name='name_value', - revision_id='revision_id_value', - version_tag='version_tag_value', - display_name='display_name_value', - type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, - active=True, - role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.PhraseMatcher.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.create_phrase_matcher(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.PhraseMatcher) - assert response.name == 'name_value' - assert response.revision_id == 'revision_id_value' - assert response.version_tag == 'version_tag_value' - assert response.display_name == 'display_name_value' - assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF - assert response.active is True - assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT - - -def test_create_phrase_matcher_rest_required_fields(request_type=contact_center_insights.CreatePhraseMatcherRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_phrase_matcher._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_phrase_matcher._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.PhraseMatcher() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = resources.PhraseMatcher.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.create_phrase_matcher(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_phrase_matcher_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_phrase_matcher._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent", "phraseMatcher", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_phrase_matcher_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_create_phrase_matcher") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_create_phrase_matcher") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.CreatePhraseMatcherRequest.pb(contact_center_insights.CreatePhraseMatcherRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = resources.PhraseMatcher.to_json(resources.PhraseMatcher()) - - request = contact_center_insights.CreatePhraseMatcherRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = resources.PhraseMatcher() - - client.create_phrase_matcher(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_create_phrase_matcher_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.CreatePhraseMatcherRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["phrase_matcher"] = {'name': 'name_value', 'revision_id': 'revision_id_value', 'version_tag': 'version_tag_value', 'revision_create_time': {'seconds': 751, 'nanos': 543}, 'display_name': 'display_name_value', 'type_': 1, 'active': True, 'phrase_match_rule_groups': [{'type_': 1, 'phrase_match_rules': [{'query': 'query_value', 'negated': True, 'config': {'exact_match_config': {'case_sensitive': True}}}]}], 'activation_update_time': {}, 'role_match': 1, 'update_time': {}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.create_phrase_matcher(request) - - -def test_create_phrase_matcher_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.PhraseMatcher() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - phrase_matcher=resources.PhraseMatcher(name='name_value'), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.PhraseMatcher.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.create_phrase_matcher(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/phraseMatchers" % client.transport._host, args[1]) - - -def test_create_phrase_matcher_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_phrase_matcher( - contact_center_insights.CreatePhraseMatcherRequest(), - parent='parent_value', - phrase_matcher=resources.PhraseMatcher(name='name_value'), - ) - - -def test_create_phrase_matcher_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.GetPhraseMatcherRequest, - dict, -]) -def test_get_phrase_matcher_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.PhraseMatcher( - name='name_value', - revision_id='revision_id_value', - version_tag='version_tag_value', - display_name='display_name_value', - type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, - active=True, - role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.PhraseMatcher.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_phrase_matcher(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.PhraseMatcher) - assert response.name == 'name_value' - assert response.revision_id == 'revision_id_value' - assert response.version_tag == 'version_tag_value' - assert response.display_name == 'display_name_value' - assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF - assert response.active is True - assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT - - -def test_get_phrase_matcher_rest_required_fields(request_type=contact_center_insights.GetPhraseMatcherRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_phrase_matcher._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_phrase_matcher._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.PhraseMatcher() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = resources.PhraseMatcher.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_phrase_matcher(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_phrase_matcher_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_phrase_matcher._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_phrase_matcher_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_get_phrase_matcher") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_get_phrase_matcher") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.GetPhraseMatcherRequest.pb(contact_center_insights.GetPhraseMatcherRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = resources.PhraseMatcher.to_json(resources.PhraseMatcher()) - - request = contact_center_insights.GetPhraseMatcherRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = resources.PhraseMatcher() - - client.get_phrase_matcher(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_phrase_matcher_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.GetPhraseMatcherRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_phrase_matcher(request) - - -def test_get_phrase_matcher_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.PhraseMatcher() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.PhraseMatcher.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_phrase_matcher(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/phraseMatchers/*}" % client.transport._host, args[1]) - - -def test_get_phrase_matcher_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_phrase_matcher( - contact_center_insights.GetPhraseMatcherRequest(), - name='name_value', - ) - - -def test_get_phrase_matcher_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.ListPhraseMatchersRequest, - dict, -]) -def test_list_phrase_matchers_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListPhraseMatchersResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = contact_center_insights.ListPhraseMatchersResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_phrase_matchers(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPhraseMatchersPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_phrase_matchers_rest_required_fields(request_type=contact_center_insights.ListPhraseMatchersRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_phrase_matchers._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_phrase_matchers._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("filter", "page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListPhraseMatchersResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = contact_center_insights.ListPhraseMatchersResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_phrase_matchers(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_phrase_matchers_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_phrase_matchers._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "pageSize", "pageToken", )) & set(("parent", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_phrase_matchers_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_list_phrase_matchers") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_list_phrase_matchers") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.ListPhraseMatchersRequest.pb(contact_center_insights.ListPhraseMatchersRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = contact_center_insights.ListPhraseMatchersResponse.to_json(contact_center_insights.ListPhraseMatchersResponse()) - - request = contact_center_insights.ListPhraseMatchersRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = contact_center_insights.ListPhraseMatchersResponse() - - client.list_phrase_matchers(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_phrase_matchers_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.ListPhraseMatchersRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_phrase_matchers(request) - - -def test_list_phrase_matchers_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListPhraseMatchersResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = contact_center_insights.ListPhraseMatchersResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_phrase_matchers(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/phraseMatchers" % client.transport._host, args[1]) - - -def test_list_phrase_matchers_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_phrase_matchers( - contact_center_insights.ListPhraseMatchersRequest(), - parent='parent_value', - ) - - -def test_list_phrase_matchers_rest_pager(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[ - resources.PhraseMatcher(), - resources.PhraseMatcher(), - resources.PhraseMatcher(), - ], - next_page_token='abc', - ), - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[], - next_page_token='def', - ), - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[ - resources.PhraseMatcher(), - ], - next_page_token='ghi', - ), - contact_center_insights.ListPhraseMatchersResponse( - phrase_matchers=[ - resources.PhraseMatcher(), - resources.PhraseMatcher(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(contact_center_insights.ListPhraseMatchersResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - pager = client.list_phrase_matchers(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.PhraseMatcher) - for i in results) - - pages = list(client.list_phrase_matchers(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.DeletePhraseMatcherRequest, - dict, -]) -def test_delete_phrase_matcher_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_phrase_matcher(request) - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_phrase_matcher_rest_required_fields(request_type=contact_center_insights.DeletePhraseMatcherRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_phrase_matcher._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_phrase_matcher._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = None - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.delete_phrase_matcher(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_phrase_matcher_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_phrase_matcher._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_phrase_matcher_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_delete_phrase_matcher") as pre: - pre.assert_not_called() - pb_message = contact_center_insights.DeletePhraseMatcherRequest.pb(contact_center_insights.DeletePhraseMatcherRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - - request = contact_center_insights.DeletePhraseMatcherRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - - client.delete_phrase_matcher(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - - -def test_delete_phrase_matcher_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.DeletePhraseMatcherRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.delete_phrase_matcher(request) - - -def test_delete_phrase_matcher_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_phrase_matcher(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/phraseMatchers/*}" % client.transport._host, args[1]) - - -def test_delete_phrase_matcher_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_phrase_matcher( - contact_center_insights.DeletePhraseMatcherRequest(), - name='name_value', - ) - - -def test_delete_phrase_matcher_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.UpdatePhraseMatcherRequest, - dict, -]) -def test_update_phrase_matcher_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'phrase_matcher': {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3'}} - request_init["phrase_matcher"] = {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3', 'revision_id': 'revision_id_value', 'version_tag': 'version_tag_value', 'revision_create_time': {'seconds': 751, 'nanos': 543}, 'display_name': 'display_name_value', 'type_': 1, 'active': True, 'phrase_match_rule_groups': [{'type_': 1, 'phrase_match_rules': [{'query': 'query_value', 'negated': True, 'config': {'exact_match_config': {'case_sensitive': True}}}]}], 'activation_update_time': {}, 'role_match': 1, 'update_time': {}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.PhraseMatcher( - name='name_value', - revision_id='revision_id_value', - version_tag='version_tag_value', - display_name='display_name_value', - type_=resources.PhraseMatcher.PhraseMatcherType.ALL_OF, - active=True, - role_match=resources.ConversationParticipant.Role.HUMAN_AGENT, - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.PhraseMatcher.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_phrase_matcher(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.PhraseMatcher) - assert response.name == 'name_value' - assert response.revision_id == 'revision_id_value' - assert response.version_tag == 'version_tag_value' - assert response.display_name == 'display_name_value' - assert response.type_ == resources.PhraseMatcher.PhraseMatcherType.ALL_OF - assert response.active is True - assert response.role_match == resources.ConversationParticipant.Role.HUMAN_AGENT - - -def test_update_phrase_matcher_rest_required_fields(request_type=contact_center_insights.UpdatePhraseMatcherRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_phrase_matcher._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_phrase_matcher._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.PhraseMatcher() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "patch", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = resources.PhraseMatcher.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.update_phrase_matcher(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_phrase_matcher_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_phrase_matcher._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("phraseMatcher", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_phrase_matcher_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_update_phrase_matcher") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_update_phrase_matcher") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.UpdatePhraseMatcherRequest.pb(contact_center_insights.UpdatePhraseMatcherRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = resources.PhraseMatcher.to_json(resources.PhraseMatcher()) - - request = contact_center_insights.UpdatePhraseMatcherRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = resources.PhraseMatcher() - - client.update_phrase_matcher(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_phrase_matcher_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.UpdatePhraseMatcherRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'phrase_matcher': {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3'}} - request_init["phrase_matcher"] = {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3', 'revision_id': 'revision_id_value', 'version_tag': 'version_tag_value', 'revision_create_time': {'seconds': 751, 'nanos': 543}, 'display_name': 'display_name_value', 'type_': 1, 'active': True, 'phrase_match_rule_groups': [{'type_': 1, 'phrase_match_rules': [{'query': 'query_value', 'negated': True, 'config': {'exact_match_config': {'case_sensitive': True}}}]}], 'activation_update_time': {}, 'role_match': 1, 'update_time': {}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.update_phrase_matcher(request) - - -def test_update_phrase_matcher_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.PhraseMatcher() - - # get arguments that satisfy an http rule for this method - sample_request = {'phrase_matcher': {'name': 'projects/sample1/locations/sample2/phraseMatchers/sample3'}} - - # get truthy value for each flattened field - mock_args = dict( - phrase_matcher=resources.PhraseMatcher(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.PhraseMatcher.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_phrase_matcher(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{phrase_matcher.name=projects/*/locations/*/phraseMatchers/*}" % client.transport._host, args[1]) - - -def test_update_phrase_matcher_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_phrase_matcher( - contact_center_insights.UpdatePhraseMatcherRequest(), - phrase_matcher=resources.PhraseMatcher(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_update_phrase_matcher_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.CalculateStatsRequest, - dict, -]) -def test_calculate_stats_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'location': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.CalculateStatsResponse( - average_turn_count=1931, - conversation_count=1955, - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = contact_center_insights.CalculateStatsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.calculate_stats(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, contact_center_insights.CalculateStatsResponse) - assert response.average_turn_count == 1931 - assert response.conversation_count == 1955 - - -def test_calculate_stats_rest_required_fields(request_type=contact_center_insights.CalculateStatsRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["location"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).calculate_stats._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["location"] = 'location_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).calculate_stats._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("filter", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "location" in jsonified_request - assert jsonified_request["location"] == 'location_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.CalculateStatsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = contact_center_insights.CalculateStatsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.calculate_stats(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_calculate_stats_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.calculate_stats._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", )) & set(("location", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_calculate_stats_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_calculate_stats") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_calculate_stats") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.CalculateStatsRequest.pb(contact_center_insights.CalculateStatsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = contact_center_insights.CalculateStatsResponse.to_json(contact_center_insights.CalculateStatsResponse()) - - request = contact_center_insights.CalculateStatsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = contact_center_insights.CalculateStatsResponse() - - client.calculate_stats(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_calculate_stats_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.CalculateStatsRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'location': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.calculate_stats(request) - - -def test_calculate_stats_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.CalculateStatsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'location': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - location='location_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = contact_center_insights.CalculateStatsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.calculate_stats(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{location=projects/*/locations/*}/conversations:calculateStats" % client.transport._host, args[1]) - - -def test_calculate_stats_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.calculate_stats( - contact_center_insights.CalculateStatsRequest(), - location='location_value', - ) - - -def test_calculate_stats_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.GetSettingsRequest, - dict, -]) -def test_get_settings_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/settings'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.Settings( - name='name_value', - language_code='language_code_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.Settings.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_settings(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Settings) - assert response.name == 'name_value' - assert response.language_code == 'language_code_value' - - -def test_get_settings_rest_required_fields(request_type=contact_center_insights.GetSettingsRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_settings._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_settings._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.Settings() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = resources.Settings.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_settings(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_settings_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_settings._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_settings_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_get_settings") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_get_settings") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.GetSettingsRequest.pb(contact_center_insights.GetSettingsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = resources.Settings.to_json(resources.Settings()) - - request = contact_center_insights.GetSettingsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = resources.Settings() - - client.get_settings(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_settings_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.GetSettingsRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/settings'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_settings(request) - - -def test_get_settings_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.Settings() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/settings'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.Settings.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_settings(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/settings}" % client.transport._host, args[1]) - - -def test_get_settings_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_settings( - contact_center_insights.GetSettingsRequest(), - name='name_value', - ) - - -def test_get_settings_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.UpdateSettingsRequest, - dict, -]) -def test_update_settings_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'settings': {'name': 'projects/sample1/locations/sample2/settings'}} - request_init["settings"] = {'name': 'projects/sample1/locations/sample2/settings', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'language_code': 'language_code_value', 'conversation_ttl': {'seconds': 751, 'nanos': 543}, 'pubsub_notification_settings': {}, 'analysis_config': {'runtime_integration_analysis_percentage': 0.4167, 'upload_conversation_analysis_percentage': 0.41590000000000005, 'annotator_selector': {'run_interruption_annotator': True, 'run_silence_annotator': True, 'run_phrase_matcher_annotator': True, 'phrase_matchers': ['phrase_matchers_value1', 'phrase_matchers_value2'], 'run_sentiment_annotator': True, 'run_entity_annotator': True, 'run_intent_annotator': True, 'run_issue_model_annotator': True, 'issue_models': ['issue_models_value1', 'issue_models_value2'], 'run_summarization_annotator': True, 'summarization_config': {'conversation_profile': 'conversation_profile_value', 'summarization_model': 1}}}, 'redaction_config': {'deidentify_template': 'deidentify_template_value', 'inspect_template': 'inspect_template_value'}, 'speech_config': {'speech_recognizer': 'speech_recognizer_value'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.Settings( - name='name_value', - language_code='language_code_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.Settings.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_settings(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.Settings) - assert response.name == 'name_value' - assert response.language_code == 'language_code_value' - - -def test_update_settings_rest_required_fields(request_type=contact_center_insights.UpdateSettingsRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_settings._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_settings._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.Settings() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "patch", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = resources.Settings.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.update_settings(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_settings_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_settings._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("settings", "updateMask", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_settings_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_update_settings") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_update_settings") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.UpdateSettingsRequest.pb(contact_center_insights.UpdateSettingsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = resources.Settings.to_json(resources.Settings()) - - request = contact_center_insights.UpdateSettingsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = resources.Settings() - - client.update_settings(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_settings_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.UpdateSettingsRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'settings': {'name': 'projects/sample1/locations/sample2/settings'}} - request_init["settings"] = {'name': 'projects/sample1/locations/sample2/settings', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'language_code': 'language_code_value', 'conversation_ttl': {'seconds': 751, 'nanos': 543}, 'pubsub_notification_settings': {}, 'analysis_config': {'runtime_integration_analysis_percentage': 0.4167, 'upload_conversation_analysis_percentage': 0.41590000000000005, 'annotator_selector': {'run_interruption_annotator': True, 'run_silence_annotator': True, 'run_phrase_matcher_annotator': True, 'phrase_matchers': ['phrase_matchers_value1', 'phrase_matchers_value2'], 'run_sentiment_annotator': True, 'run_entity_annotator': True, 'run_intent_annotator': True, 'run_issue_model_annotator': True, 'issue_models': ['issue_models_value1', 'issue_models_value2'], 'run_summarization_annotator': True, 'summarization_config': {'conversation_profile': 'conversation_profile_value', 'summarization_model': 1}}}, 'redaction_config': {'deidentify_template': 'deidentify_template_value', 'inspect_template': 'inspect_template_value'}, 'speech_config': {'speech_recognizer': 'speech_recognizer_value'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.update_settings(request) - - -def test_update_settings_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.Settings() - - # get arguments that satisfy an http rule for this method - sample_request = {'settings': {'name': 'projects/sample1/locations/sample2/settings'}} - - # get truthy value for each flattened field - mock_args = dict( - settings=resources.Settings(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.Settings.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_settings(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{settings.name=projects/*/locations/*/settings}" % client.transport._host, args[1]) - - -def test_update_settings_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_settings( - contact_center_insights.UpdateSettingsRequest(), - settings=resources.Settings(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_update_settings_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.CreateViewRequest, - dict, -]) -def test_create_view_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["view"] = {'name': 'name_value', 'display_name': 'display_name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'value': 'value_value'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.View( - name='name_value', - display_name='display_name_value', - value='value_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.View.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.create_view(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.View) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.value == 'value_value' - - -def test_create_view_rest_required_fields(request_type=contact_center_insights.CreateViewRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_view._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_view._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.View() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = resources.View.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.create_view(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_view_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_view._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent", "view", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_view_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_create_view") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_create_view") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.CreateViewRequest.pb(contact_center_insights.CreateViewRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = resources.View.to_json(resources.View()) - - request = contact_center_insights.CreateViewRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = resources.View() - - client.create_view(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_create_view_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.CreateViewRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["view"] = {'name': 'name_value', 'display_name': 'display_name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'value': 'value_value'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.create_view(request) - - -def test_create_view_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.View() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - view=resources.View(name='name_value'), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.View.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.create_view(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/views" % client.transport._host, args[1]) - - -def test_create_view_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_view( - contact_center_insights.CreateViewRequest(), - parent='parent_value', - view=resources.View(name='name_value'), - ) - - -def test_create_view_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.GetViewRequest, - dict, -]) -def test_get_view_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/views/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.View( - name='name_value', - display_name='display_name_value', - value='value_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.View.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_view(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.View) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.value == 'value_value' - - -def test_get_view_rest_required_fields(request_type=contact_center_insights.GetViewRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_view._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_view._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.View() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = resources.View.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_view(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_view_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_view._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_view_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_get_view") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_get_view") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.GetViewRequest.pb(contact_center_insights.GetViewRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = resources.View.to_json(resources.View()) - - request = contact_center_insights.GetViewRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = resources.View() - - client.get_view(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_view_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.GetViewRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/views/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_view(request) - - -def test_get_view_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.View() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/views/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.View.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_view(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/views/*}" % client.transport._host, args[1]) - - -def test_get_view_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_view( - contact_center_insights.GetViewRequest(), - name='name_value', - ) - - -def test_get_view_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.ListViewsRequest, - dict, -]) -def test_list_views_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListViewsResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = contact_center_insights.ListViewsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_views(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListViewsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_views_rest_required_fields(request_type=contact_center_insights.ListViewsRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_views._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_views._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListViewsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = contact_center_insights.ListViewsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_views(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_views_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_views._get_unset_required_fields({}) - assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_views_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_list_views") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_list_views") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.ListViewsRequest.pb(contact_center_insights.ListViewsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = contact_center_insights.ListViewsResponse.to_json(contact_center_insights.ListViewsResponse()) - - request = contact_center_insights.ListViewsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = contact_center_insights.ListViewsResponse() - - client.list_views(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_views_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.ListViewsRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_views(request) - - -def test_list_views_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = contact_center_insights.ListViewsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = contact_center_insights.ListViewsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_views(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/views" % client.transport._host, args[1]) - - -def test_list_views_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_views( - contact_center_insights.ListViewsRequest(), - parent='parent_value', - ) - - -def test_list_views_rest_pager(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - resources.View(), - resources.View(), - ], - next_page_token='abc', - ), - contact_center_insights.ListViewsResponse( - views=[], - next_page_token='def', - ), - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - ], - next_page_token='ghi', - ), - contact_center_insights.ListViewsResponse( - views=[ - resources.View(), - resources.View(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(contact_center_insights.ListViewsResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - pager = client.list_views(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, resources.View) - for i in results) - - pages = list(client.list_views(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.UpdateViewRequest, - dict, -]) -def test_update_view_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'view': {'name': 'projects/sample1/locations/sample2/views/sample3'}} - request_init["view"] = {'name': 'projects/sample1/locations/sample2/views/sample3', 'display_name': 'display_name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'value': 'value_value'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.View( - name='name_value', - display_name='display_name_value', - value='value_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.View.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_view(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, resources.View) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.value == 'value_value' - - -def test_update_view_rest_required_fields(request_type=contact_center_insights.UpdateViewRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_view._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_view._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = resources.View() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "patch", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - pb_return_value = resources.View.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.update_view(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_view_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_view._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("view", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_view_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "post_update_view") as post, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_update_view") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = contact_center_insights.UpdateViewRequest.pb(contact_center_insights.UpdateViewRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = resources.View.to_json(resources.View()) - - request = contact_center_insights.UpdateViewRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = resources.View() - - client.update_view(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_view_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.UpdateViewRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'view': {'name': 'projects/sample1/locations/sample2/views/sample3'}} - request_init["view"] = {'name': 'projects/sample1/locations/sample2/views/sample3', 'display_name': 'display_name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'value': 'value_value'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.update_view(request) - - -def test_update_view_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = resources.View() - - # get arguments that satisfy an http rule for this method - sample_request = {'view': {'name': 'projects/sample1/locations/sample2/views/sample3'}} - - # get truthy value for each flattened field - mock_args = dict( - view=resources.View(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - pb_return_value = resources.View.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_view(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{view.name=projects/*/locations/*/views/*}" % client.transport._host, args[1]) - - -def test_update_view_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_view( - contact_center_insights.UpdateViewRequest(), - view=resources.View(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_update_view_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - contact_center_insights.DeleteViewRequest, - dict, -]) -def test_delete_view_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/views/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_view(request) - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_view_rest_required_fields(request_type=contact_center_insights.DeleteViewRequest): - transport_class = transports.ContactCenterInsightsRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_view._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_view._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = None - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.delete_view(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_view_rest_unset_required_fields(): - transport = transports.ContactCenterInsightsRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_view._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_view_rest_interceptors(null_interceptor): - transport = transports.ContactCenterInsightsRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ContactCenterInsightsRestInterceptor(), - ) - client = ContactCenterInsightsClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ContactCenterInsightsRestInterceptor, "pre_delete_view") as pre: - pre.assert_not_called() - pb_message = contact_center_insights.DeleteViewRequest.pb(contact_center_insights.DeleteViewRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - - request = contact_center_insights.DeleteViewRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - - client.delete_view(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - - -def test_delete_view_rest_bad_request(transport: str = 'rest', request_type=contact_center_insights.DeleteViewRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/views/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.delete_view(request) - - -def test_delete_view_rest_flattened(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/views/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_view(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/views/*}" % client.transport._host, args[1]) - - -def test_delete_view_rest_flattened_error(transport: str = 'rest'): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_view( - contact_center_insights.DeleteViewRequest(), - name='name_value', - ) - - -def test_delete_view_rest_error(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.ContactCenterInsightsGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.ContactCenterInsightsGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = ContactCenterInsightsClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide an api_key and a transport instance. - transport = transports.ContactCenterInsightsGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = ContactCenterInsightsClient( - client_options=options, - transport=transport, - ) - - # It is an error to provide an api_key and a credential. - options = mock.Mock() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = ContactCenterInsightsClient( - client_options=options, - credentials=ga_credentials.AnonymousCredentials() - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.ContactCenterInsightsGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = ContactCenterInsightsClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.ContactCenterInsightsGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = ContactCenterInsightsClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.ContactCenterInsightsGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.ContactCenterInsightsGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.ContactCenterInsightsGrpcTransport, - transports.ContactCenterInsightsGrpcAsyncIOTransport, - transports.ContactCenterInsightsRestTransport, -]) -def test_transport_adc(transport_class): - # Test default credentials are used if not provided. - with mock.patch.object(google.auth, 'default') as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class() - adc.assert_called_once() - -@pytest.mark.parametrize("transport_name", [ - "grpc", - "rest", -]) -def test_transport_kind(transport_name): - transport = ContactCenterInsightsClient.get_transport_class(transport_name)( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert transport.kind == transport_name - -def test_transport_grpc_default(): - # A client should use the gRPC transport by default. - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.ContactCenterInsightsGrpcTransport, - ) - -def test_contact_center_insights_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.ContactCenterInsightsTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_contact_center_insights_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.contact_center_insights_v1.services.contact_center_insights.transports.ContactCenterInsightsTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.ContactCenterInsightsTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'create_conversation', - 'upload_conversation', - 'update_conversation', - 'get_conversation', - 'list_conversations', - 'delete_conversation', - 'create_analysis', - 'get_analysis', - 'list_analyses', - 'delete_analysis', - 'bulk_analyze_conversations', - 'ingest_conversations', - 'export_insights_data', - 'create_issue_model', - 'update_issue_model', - 'get_issue_model', - 'list_issue_models', - 'delete_issue_model', - 'deploy_issue_model', - 'undeploy_issue_model', - 'get_issue', - 'list_issues', - 'update_issue', - 'delete_issue', - 'calculate_issue_model_stats', - 'create_phrase_matcher', - 'get_phrase_matcher', - 'list_phrase_matchers', - 'delete_phrase_matcher', - 'update_phrase_matcher', - 'calculate_stats', - 'get_settings', - 'update_settings', - 'create_view', - 'get_view', - 'list_views', - 'update_view', - 'delete_view', - 'get_operation', - 'cancel_operation', - 'list_operations', - ) - for method in methods: - with pytest.raises(NotImplementedError): - getattr(transport, method)(request=object()) - - with pytest.raises(NotImplementedError): - transport.close() - - # Additionally, the LRO client (a property) should - # also raise NotImplementedError - with pytest.raises(NotImplementedError): - transport.operations_client - - # Catch all for all remaining methods and properties - remainder = [ - 'kind', - ] - for r in remainder: - with pytest.raises(NotImplementedError): - getattr(transport, r)() - - -def test_contact_center_insights_base_transport_with_credentials_file(): - # Instantiate the base transport with a credentials file - with mock.patch.object(google.auth, 'load_credentials_from_file', autospec=True) as load_creds, mock.patch('google.cloud.contact_center_insights_v1.services.contact_center_insights.transports.ContactCenterInsightsTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.ContactCenterInsightsTransport( - credentials_file="credentials.json", - quota_project_id="octopus", - ) - load_creds.assert_called_once_with("credentials.json", - scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - quota_project_id="octopus", - ) - - -def test_contact_center_insights_base_transport_with_adc(): - # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.contact_center_insights_v1.services.contact_center_insights.transports.ContactCenterInsightsTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.ContactCenterInsightsTransport() - adc.assert_called_once() - - -def test_contact_center_insights_auth_adc(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - ContactCenterInsightsClient() - adc.assert_called_once_with( - scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - quota_project_id=None, - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.ContactCenterInsightsGrpcTransport, - transports.ContactCenterInsightsGrpcAsyncIOTransport, - ], -) -def test_contact_center_insights_transport_auth_adc(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus", scopes=["1", "2"]) - adc.assert_called_once_with( - scopes=["1", "2"], - default_scopes=( 'https://www.googleapis.com/auth/cloud-platform',), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.ContactCenterInsightsGrpcTransport, - transports.ContactCenterInsightsGrpcAsyncIOTransport, - transports.ContactCenterInsightsRestTransport, - ], -) -def test_contact_center_insights_transport_auth_gdch_credentials(transport_class): - host = 'https://language.com' - api_audience_tests = [None, 'https://language2.com'] - api_audience_expect = [host, 'https://language2.com'] - for t, e in zip(api_audience_tests, api_audience_expect): - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - gdch_mock = mock.MagicMock() - type(gdch_mock).with_gdch_audience = mock.PropertyMock(return_value=gdch_mock) - adc.return_value = (gdch_mock, None) - transport_class(host=host, api_audience=t) - gdch_mock.with_gdch_audience.assert_called_once_with( - e - ) - - -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.ContactCenterInsightsGrpcTransport, grpc_helpers), - (transports.ContactCenterInsightsGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -def test_contact_center_insights_transport_create_channel(transport_class, grpc_helpers): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( - grpc_helpers, "create_channel", autospec=True - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - adc.return_value = (creds, None) - transport_class( - quota_project_id="octopus", - scopes=["1", "2"] - ) - - create_channel.assert_called_with( - "contactcenterinsights.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - scopes=["1", "2"], - default_host="contactcenterinsights.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize("transport_class", [transports.ContactCenterInsightsGrpcTransport, transports.ContactCenterInsightsGrpcAsyncIOTransport]) -def test_contact_center_insights_grpc_transport_client_cert_source_for_mtls( - transport_class -): - cred = ga_credentials.AnonymousCredentials() - - # Check ssl_channel_credentials is used if provided. - with mock.patch.object(transport_class, "create_channel") as mock_create_channel: - mock_ssl_channel_creds = mock.Mock() - transport_class( - host="squid.clam.whelk", - credentials=cred, - ssl_channel_credentials=mock_ssl_channel_creds - ) - mock_create_channel.assert_called_once_with( - "squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_channel_creds, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls - # is used. - with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): - with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: - transport_class( - credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback - ) - expected_cert, expected_key = client_cert_source_callback() - mock_ssl_cred.assert_called_once_with( - certificate_chain=expected_cert, - private_key=expected_key - ) - -def test_contact_center_insights_http_transport_client_cert_source_for_mtls(): - cred = ga_credentials.AnonymousCredentials() - with mock.patch("google.auth.transport.requests.AuthorizedSession.configure_mtls_channel") as mock_configure_mtls_channel: - transports.ContactCenterInsightsRestTransport ( - credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback - ) - mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback) - - -def test_contact_center_insights_rest_lro_client(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.AbstractOperationsClient, - ) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -@pytest.mark.parametrize("transport_name", [ - "grpc", - "grpc_asyncio", - "rest", -]) -def test_contact_center_insights_host_no_port(transport_name): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='contactcenterinsights.googleapis.com'), - transport=transport_name, - ) - assert client.transport._host == ( - 'contactcenterinsights.googleapis.com:443' - if transport_name in ['grpc', 'grpc_asyncio'] - else 'https://contactcenterinsights.googleapis.com' - ) - -@pytest.mark.parametrize("transport_name", [ - "grpc", - "grpc_asyncio", - "rest", -]) -def test_contact_center_insights_host_with_port(transport_name): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='contactcenterinsights.googleapis.com:8000'), - transport=transport_name, - ) - assert client.transport._host == ( - 'contactcenterinsights.googleapis.com:8000' - if transport_name in ['grpc', 'grpc_asyncio'] - else 'https://contactcenterinsights.googleapis.com:8000' - ) - -@pytest.mark.parametrize("transport_name", [ - "rest", -]) -def test_contact_center_insights_client_transport_session_collision(transport_name): - creds1 = ga_credentials.AnonymousCredentials() - creds2 = ga_credentials.AnonymousCredentials() - client1 = ContactCenterInsightsClient( - credentials=creds1, - transport=transport_name, - ) - client2 = ContactCenterInsightsClient( - credentials=creds2, - transport=transport_name, - ) - session1 = client1.transport.create_conversation._session - session2 = client2.transport.create_conversation._session - assert session1 != session2 - session1 = client1.transport.upload_conversation._session - session2 = client2.transport.upload_conversation._session - assert session1 != session2 - session1 = client1.transport.update_conversation._session - session2 = client2.transport.update_conversation._session - assert session1 != session2 - session1 = client1.transport.get_conversation._session - session2 = client2.transport.get_conversation._session - assert session1 != session2 - session1 = client1.transport.list_conversations._session - session2 = client2.transport.list_conversations._session - assert session1 != session2 - session1 = client1.transport.delete_conversation._session - session2 = client2.transport.delete_conversation._session - assert session1 != session2 - session1 = client1.transport.create_analysis._session - session2 = client2.transport.create_analysis._session - assert session1 != session2 - session1 = client1.transport.get_analysis._session - session2 = client2.transport.get_analysis._session - assert session1 != session2 - session1 = client1.transport.list_analyses._session - session2 = client2.transport.list_analyses._session - assert session1 != session2 - session1 = client1.transport.delete_analysis._session - session2 = client2.transport.delete_analysis._session - assert session1 != session2 - session1 = client1.transport.bulk_analyze_conversations._session - session2 = client2.transport.bulk_analyze_conversations._session - assert session1 != session2 - session1 = client1.transport.ingest_conversations._session - session2 = client2.transport.ingest_conversations._session - assert session1 != session2 - session1 = client1.transport.export_insights_data._session - session2 = client2.transport.export_insights_data._session - assert session1 != session2 - session1 = client1.transport.create_issue_model._session - session2 = client2.transport.create_issue_model._session - assert session1 != session2 - session1 = client1.transport.update_issue_model._session - session2 = client2.transport.update_issue_model._session - assert session1 != session2 - session1 = client1.transport.get_issue_model._session - session2 = client2.transport.get_issue_model._session - assert session1 != session2 - session1 = client1.transport.list_issue_models._session - session2 = client2.transport.list_issue_models._session - assert session1 != session2 - session1 = client1.transport.delete_issue_model._session - session2 = client2.transport.delete_issue_model._session - assert session1 != session2 - session1 = client1.transport.deploy_issue_model._session - session2 = client2.transport.deploy_issue_model._session - assert session1 != session2 - session1 = client1.transport.undeploy_issue_model._session - session2 = client2.transport.undeploy_issue_model._session - assert session1 != session2 - session1 = client1.transport.get_issue._session - session2 = client2.transport.get_issue._session - assert session1 != session2 - session1 = client1.transport.list_issues._session - session2 = client2.transport.list_issues._session - assert session1 != session2 - session1 = client1.transport.update_issue._session - session2 = client2.transport.update_issue._session - assert session1 != session2 - session1 = client1.transport.delete_issue._session - session2 = client2.transport.delete_issue._session - assert session1 != session2 - session1 = client1.transport.calculate_issue_model_stats._session - session2 = client2.transport.calculate_issue_model_stats._session - assert session1 != session2 - session1 = client1.transport.create_phrase_matcher._session - session2 = client2.transport.create_phrase_matcher._session - assert session1 != session2 - session1 = client1.transport.get_phrase_matcher._session - session2 = client2.transport.get_phrase_matcher._session - assert session1 != session2 - session1 = client1.transport.list_phrase_matchers._session - session2 = client2.transport.list_phrase_matchers._session - assert session1 != session2 - session1 = client1.transport.delete_phrase_matcher._session - session2 = client2.transport.delete_phrase_matcher._session - assert session1 != session2 - session1 = client1.transport.update_phrase_matcher._session - session2 = client2.transport.update_phrase_matcher._session - assert session1 != session2 - session1 = client1.transport.calculate_stats._session - session2 = client2.transport.calculate_stats._session - assert session1 != session2 - session1 = client1.transport.get_settings._session - session2 = client2.transport.get_settings._session - assert session1 != session2 - session1 = client1.transport.update_settings._session - session2 = client2.transport.update_settings._session - assert session1 != session2 - session1 = client1.transport.create_view._session - session2 = client2.transport.create_view._session - assert session1 != session2 - session1 = client1.transport.get_view._session - session2 = client2.transport.get_view._session - assert session1 != session2 - session1 = client1.transport.list_views._session - session2 = client2.transport.list_views._session - assert session1 != session2 - session1 = client1.transport.update_view._session - session2 = client2.transport.update_view._session - assert session1 != session2 - session1 = client1.transport.delete_view._session - session2 = client2.transport.delete_view._session - assert session1 != session2 -def test_contact_center_insights_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.ContactCenterInsightsGrpcTransport( - host="squid.clam.whelk", - channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -def test_contact_center_insights_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.ContactCenterInsightsGrpcAsyncIOTransport( - host="squid.clam.whelk", - channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.ContactCenterInsightsGrpcTransport, transports.ContactCenterInsightsGrpcAsyncIOTransport]) -def test_contact_center_insights_transport_channel_mtls_with_client_cert_source( - transport_class -): - with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: - mock_ssl_cred = mock.Mock() - grpc_ssl_channel_cred.return_value = mock_ssl_cred - - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - - cred = ga_credentials.AnonymousCredentials() - with pytest.warns(DeprecationWarning): - with mock.patch.object(google.auth, 'default') as adc: - adc.return_value = (cred, None) - transport = transport_class( - host="squid.clam.whelk", - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=client_cert_source_callback, - ) - adc.assert_called_once() - - grpc_ssl_channel_cred.assert_called_once_with( - certificate_chain=b"cert bytes", private_key=b"key bytes" - ) - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - assert transport._ssl_channel_credentials == mock_ssl_cred - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.ContactCenterInsightsGrpcTransport, transports.ContactCenterInsightsGrpcAsyncIOTransport]) -def test_contact_center_insights_transport_channel_mtls_with_adc( - transport_class -): - mock_ssl_cred = mock.Mock() - with mock.patch.multiple( - "google.auth.transport.grpc.SslCredentials", - __init__=mock.Mock(return_value=None), - ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), - ): - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - mock_cred = mock.Mock() - - with pytest.warns(DeprecationWarning): - transport = transport_class( - host="squid.clam.whelk", - credentials=mock_cred, - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=None, - ) - - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=mock_cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - - -def test_contact_center_insights_grpc_lro_client(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsClient, - ) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -def test_contact_center_insights_grpc_lro_async_client(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc_asyncio', - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsAsyncClient, - ) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -def test_analysis_path(): - project = "squid" - location = "clam" - conversation = "whelk" - analysis = "octopus" - expected = "projects/{project}/locations/{location}/conversations/{conversation}/analyses/{analysis}".format(project=project, location=location, conversation=conversation, analysis=analysis, ) - actual = ContactCenterInsightsClient.analysis_path(project, location, conversation, analysis) - assert expected == actual - - -def test_parse_analysis_path(): - expected = { - "project": "oyster", - "location": "nudibranch", - "conversation": "cuttlefish", - "analysis": "mussel", - } - path = ContactCenterInsightsClient.analysis_path(**expected) - - # Check that the path construction is reversible. - actual = ContactCenterInsightsClient.parse_analysis_path(path) - assert expected == actual - -def test_conversation_path(): - project = "winkle" - location = "nautilus" - conversation = "scallop" - expected = "projects/{project}/locations/{location}/conversations/{conversation}".format(project=project, location=location, conversation=conversation, ) - actual = ContactCenterInsightsClient.conversation_path(project, location, conversation) - assert expected == actual - - -def test_parse_conversation_path(): - expected = { - "project": "abalone", - "location": "squid", - "conversation": "clam", - } - path = ContactCenterInsightsClient.conversation_path(**expected) - - # Check that the path construction is reversible. - actual = ContactCenterInsightsClient.parse_conversation_path(path) - assert expected == actual - -def test_conversation_profile_path(): - project = "whelk" - location = "octopus" - conversation_profile = "oyster" - expected = "projects/{project}/locations/{location}/conversationProfiles/{conversation_profile}".format(project=project, location=location, conversation_profile=conversation_profile, ) - actual = ContactCenterInsightsClient.conversation_profile_path(project, location, conversation_profile) - assert expected == actual - - -def test_parse_conversation_profile_path(): - expected = { - "project": "nudibranch", - "location": "cuttlefish", - "conversation_profile": "mussel", - } - path = ContactCenterInsightsClient.conversation_profile_path(**expected) - - # Check that the path construction is reversible. - actual = ContactCenterInsightsClient.parse_conversation_profile_path(path) - assert expected == actual - -def test_issue_path(): - project = "winkle" - location = "nautilus" - issue_model = "scallop" - issue = "abalone" - expected = "projects/{project}/locations/{location}/issueModels/{issue_model}/issues/{issue}".format(project=project, location=location, issue_model=issue_model, issue=issue, ) - actual = ContactCenterInsightsClient.issue_path(project, location, issue_model, issue) - assert expected == actual - - -def test_parse_issue_path(): - expected = { - "project": "squid", - "location": "clam", - "issue_model": "whelk", - "issue": "octopus", - } - path = ContactCenterInsightsClient.issue_path(**expected) - - # Check that the path construction is reversible. - actual = ContactCenterInsightsClient.parse_issue_path(path) - assert expected == actual - -def test_issue_model_path(): - project = "oyster" - location = "nudibranch" - issue_model = "cuttlefish" - expected = "projects/{project}/locations/{location}/issueModels/{issue_model}".format(project=project, location=location, issue_model=issue_model, ) - actual = ContactCenterInsightsClient.issue_model_path(project, location, issue_model) - assert expected == actual - - -def test_parse_issue_model_path(): - expected = { - "project": "mussel", - "location": "winkle", - "issue_model": "nautilus", - } - path = ContactCenterInsightsClient.issue_model_path(**expected) - - # Check that the path construction is reversible. - actual = ContactCenterInsightsClient.parse_issue_model_path(path) - assert expected == actual - -def test_participant_path(): - project = "scallop" - conversation = "abalone" - participant = "squid" - expected = "projects/{project}/conversations/{conversation}/participants/{participant}".format(project=project, conversation=conversation, participant=participant, ) - actual = ContactCenterInsightsClient.participant_path(project, conversation, participant) - assert expected == actual - - -def test_parse_participant_path(): - expected = { - "project": "clam", - "conversation": "whelk", - "participant": "octopus", - } - path = ContactCenterInsightsClient.participant_path(**expected) - - # Check that the path construction is reversible. - actual = ContactCenterInsightsClient.parse_participant_path(path) - assert expected == actual - -def test_phrase_matcher_path(): - project = "oyster" - location = "nudibranch" - phrase_matcher = "cuttlefish" - expected = "projects/{project}/locations/{location}/phraseMatchers/{phrase_matcher}".format(project=project, location=location, phrase_matcher=phrase_matcher, ) - actual = ContactCenterInsightsClient.phrase_matcher_path(project, location, phrase_matcher) - assert expected == actual - - -def test_parse_phrase_matcher_path(): - expected = { - "project": "mussel", - "location": "winkle", - "phrase_matcher": "nautilus", - } - path = ContactCenterInsightsClient.phrase_matcher_path(**expected) - - # Check that the path construction is reversible. - actual = ContactCenterInsightsClient.parse_phrase_matcher_path(path) - assert expected == actual - -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, ) - actual = ContactCenterInsightsClient.settings_path(project, location) - assert expected == actual - - -def test_parse_settings_path(): - expected = { - "project": "cuttlefish", - "location": "mussel", - } - path = ContactCenterInsightsClient.settings_path(**expected) - - # Check that the path construction is reversible. - actual = ContactCenterInsightsClient.parse_settings_path(path) - assert expected == actual - -def test_view_path(): - project = "winkle" - location = "nautilus" - view = "scallop" - expected = "projects/{project}/locations/{location}/views/{view}".format(project=project, location=location, view=view, ) - actual = ContactCenterInsightsClient.view_path(project, location, view) - assert expected == actual - - -def test_parse_view_path(): - expected = { - "project": "abalone", - "location": "squid", - "view": "clam", - } - path = ContactCenterInsightsClient.view_path(**expected) - - # Check that the path construction is reversible. - actual = ContactCenterInsightsClient.parse_view_path(path) - assert expected == actual - -def test_common_billing_account_path(): - billing_account = "whelk" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - actual = ContactCenterInsightsClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "octopus", - } - path = ContactCenterInsightsClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = ContactCenterInsightsClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "oyster" - expected = "folders/{folder}".format(folder=folder, ) - actual = ContactCenterInsightsClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "nudibranch", - } - path = ContactCenterInsightsClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = ContactCenterInsightsClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "cuttlefish" - expected = "organizations/{organization}".format(organization=organization, ) - actual = ContactCenterInsightsClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "mussel", - } - path = ContactCenterInsightsClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = ContactCenterInsightsClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "winkle" - expected = "projects/{project}".format(project=project, ) - actual = ContactCenterInsightsClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "nautilus", - } - path = ContactCenterInsightsClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = ContactCenterInsightsClient.parse_common_project_path(path) - assert expected == actual - -def test_common_location_path(): - project = "scallop" - location = "abalone" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) - actual = ContactCenterInsightsClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "squid", - "location": "clam", - } - path = ContactCenterInsightsClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = ContactCenterInsightsClient.parse_common_location_path(path) - assert expected == actual - - -def test_client_with_default_client_info(): - client_info = gapic_v1.client_info.ClientInfo() - - with mock.patch.object(transports.ContactCenterInsightsTransport, '_prep_wrapped_messages') as prep: - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.ContactCenterInsightsTransport, '_prep_wrapped_messages') as prep: - transport_class = ContactCenterInsightsClient.get_transport_class() - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - -@pytest.mark.asyncio -async def test_transport_close_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc_asyncio", - ) - with mock.patch.object(type(getattr(client.transport, "grpc_channel")), "close") as close: - async with client: - close.assert_not_called() - close.assert_called_once() - - -def test_cancel_operation_rest_bad_request(transport: str = 'rest', request_type=operations_pb2.CancelOperationRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - request = request_type() - request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2/operations/sample3'}, request) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.cancel_operation(request) - -@pytest.mark.parametrize("request_type", [ - operations_pb2.CancelOperationRequest, - dict, -]) -def test_cancel_operation_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request_init = {'name': 'projects/sample1/locations/sample2/operations/sample3'} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = '{}' - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.cancel_operation(request) - - # Establish that the response is the type that we expect. - assert response is None - -def test_get_operation_rest_bad_request(transport: str = 'rest', request_type=operations_pb2.GetOperationRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - request = request_type() - request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2/operations/sample3'}, request) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_operation(request) - -@pytest.mark.parametrize("request_type", [ - operations_pb2.GetOperationRequest, - dict, -]) -def test_get_operation_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request_init = {'name': 'projects/sample1/locations/sample2/operations/sample3'} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation() - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_operation(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, operations_pb2.Operation) - -def test_list_operations_rest_bad_request(transport: str = 'rest', request_type=operations_pb2.ListOperationsRequest): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - request = request_type() - request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2'}, request) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_operations(request) - -@pytest.mark.parametrize("request_type", [ - operations_pb2.ListOperationsRequest, - dict, -]) -def test_list_operations_rest(request_type): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request_init = {'name': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.ListOperationsResponse() - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_operations(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, operations_pb2.ListOperationsResponse) - - -def test_cancel_operation(transport: str = "grpc"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = operations_pb2.CancelOperationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.cancel_operation(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the response is the type that we expect. - assert response is None -@pytest.mark.asyncio -async def test_cancel_operation_async(transport: str = "grpc"): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = operations_pb2.CancelOperationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - None - ) - response = await client.cancel_operation(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the response is the type that we expect. - assert response is None - -def test_cancel_operation_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = operations_pb2.CancelOperationRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - call.return_value = None - - client.cancel_operation(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=locations",) in kw["metadata"] -@pytest.mark.asyncio -async def test_cancel_operation_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = operations_pb2.CancelOperationRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - None - ) - await client.cancel_operation(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=locations",) in kw["metadata"] - -def test_cancel_operation_from_dict(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = None - - response = client.cancel_operation( - request={ - "name": "locations", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_cancel_operation_from_dict_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - None - ) - response = await client.cancel_operation( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_get_operation(transport: str = "grpc"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = operations_pb2.GetOperationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation() - response = client.get_operation(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, operations_pb2.Operation) -@pytest.mark.asyncio -async def test_get_operation_async(transport: str = "grpc"): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = operations_pb2.GetOperationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation() - ) - response = await client.get_operation(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, operations_pb2.Operation) - -def test_get_operation_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = operations_pb2.GetOperationRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_operation), "__call__") as call: - call.return_value = operations_pb2.Operation() - - client.get_operation(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=locations",) in kw["metadata"] -@pytest.mark.asyncio -async def test_get_operation_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = operations_pb2.GetOperationRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_operation), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation() - ) - await client.get_operation(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=locations",) in kw["metadata"] - -def test_get_operation_from_dict(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation() - - response = client.get_operation( - request={ - "name": "locations", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_get_operation_from_dict_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation() - ) - response = await client.get_operation( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_list_operations(transport: str = "grpc"): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = operations_pb2.ListOperationsRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.ListOperationsResponse() - response = client.list_operations(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, operations_pb2.ListOperationsResponse) -@pytest.mark.asyncio -async def test_list_operations_async(transport: str = "grpc"): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = operations_pb2.ListOperationsRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.ListOperationsResponse() - ) - response = await client.list_operations(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, operations_pb2.ListOperationsResponse) - -def test_list_operations_field_headers(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = operations_pb2.ListOperationsRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - call.return_value = operations_pb2.ListOperationsResponse() - - client.list_operations(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=locations",) in kw["metadata"] -@pytest.mark.asyncio -async def test_list_operations_field_headers_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = operations_pb2.ListOperationsRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.ListOperationsResponse() - ) - await client.list_operations(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=locations",) in kw["metadata"] - -def test_list_operations_from_dict(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.ListOperationsResponse() - - response = client.list_operations( - request={ - "name": "locations", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_list_operations_from_dict_async(): - client = ContactCenterInsightsAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.ListOperationsResponse() - ) - response = await client.list_operations( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_transport_close(): - transports = { - "rest": "_session", - "grpc": "_grpc_channel", - } - - for transport, close_name in transports.items(): - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport - ) - with mock.patch.object(type(getattr(client.transport, close_name)), "close") as close: - with client: - close.assert_not_called() - close.assert_called_once() - -def test_client_ctx(): - transports = [ - 'rest', - 'grpc', - ] - for transport in transports: - client = ContactCenterInsightsClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport - ) - # Test client calls underlying transport. - with mock.patch.object(type(client.transport), "close") as close: - close.assert_not_called() - with client: - pass - close.assert_called() - -@pytest.mark.parametrize("client_class,transport_class", [ - (ContactCenterInsightsClient, transports.ContactCenterInsightsGrpcTransport), - (ContactCenterInsightsAsyncClient, transports.ContactCenterInsightsGrpcAsyncIOTransport), -]) -def test_api_key_credentials(client_class, transport_class): - with mock.patch.object( - google.auth._default, "get_api_key_credentials", create=True - ) as get_api_key_credentials: - mock_cred = mock.Mock() - get_api_key_credentials.return_value = mock_cred - options = client_options.ClientOptions() - options.api_key = "api_key" - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=mock_cred, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) 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)