From f9e04f71f20c9710025b4cf844e5a89402ec3921 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Thu, 10 Aug 2023 03:56:55 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20post-p?= =?UTF-8?q?rocessor?= 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 --- google/cloud/dialogflowcx/__init__.py | 4 + google/cloud/dialogflowcx_v3/__init__.py | 4 + .../services/agents/async_client.py | 9 +- .../dialogflowcx_v3/services/agents/client.py | 9 +- .../services/agents/transports/rest.py | 15 +- .../transition_route_groups/async_client.py | 22 +- .../transition_route_groups/client.py | 22 +- .../transports/rest.py | 28 +- .../cloud/dialogflowcx_v3/types/__init__.py | 3 + google/cloud/dialogflowcx_v3/types/agent.py | 11 +- google/cloud/dialogflowcx_v3/types/flow.py | 35 +- .../dialogflowcx_v3/types/import_strategy.py | 4 +- google/cloud/dialogflowcx_v3/types/page.py | 5 +- .../dialogflowcx_v3/types/response_message.py | 32 + google/cloud/dialogflowcx_v3/types/session.py | 10 +- .../types/transition_route_group.py | 21 +- owl-bot-staging/v3/.coveragerc | 13 - owl-bot-staging/v3/.flake8 | 33 - owl-bot-staging/v3/MANIFEST.in | 2 - owl-bot-staging/v3/README.rst | 49 - owl-bot-staging/v3/docs/conf.py | 376 - .../v3/docs/dialogflowcx_v3/agents.rst | 10 - .../v3/docs/dialogflowcx_v3/changelogs.rst | 10 - .../v3/docs/dialogflowcx_v3/deployments.rst | 10 - .../v3/docs/dialogflowcx_v3/entity_types.rst | 10 - .../v3/docs/dialogflowcx_v3/environments.rst | 10 - .../v3/docs/dialogflowcx_v3/experiments.rst | 10 - .../v3/docs/dialogflowcx_v3/flows.rst | 10 - .../v3/docs/dialogflowcx_v3/intents.rst | 10 - .../v3/docs/dialogflowcx_v3/pages.rst | 10 - .../security_settings_service.rst | 10 - .../v3/docs/dialogflowcx_v3/services.rst | 21 - .../dialogflowcx_v3/session_entity_types.rst | 10 - .../v3/docs/dialogflowcx_v3/sessions.rst | 6 - .../v3/docs/dialogflowcx_v3/test_cases.rst | 10 - .../transition_route_groups.rst | 10 - .../v3/docs/dialogflowcx_v3/types.rst | 6 - .../v3/docs/dialogflowcx_v3/versions.rst | 10 - .../v3/docs/dialogflowcx_v3/webhooks.rst | 10 - owl-bot-staging/v3/docs/index.rst | 7 - .../v3/google/cloud/dialogflowcx/__init__.py | 505 - .../cloud/dialogflowcx/gapic_version.py | 16 - .../v3/google/cloud/dialogflowcx/py.typed | 2 - .../google/cloud/dialogflowcx_v3/__init__.py | 506 - .../cloud/dialogflowcx_v3/gapic_metadata.json | 1768 -- .../cloud/dialogflowcx_v3/gapic_version.py | 16 - .../v3/google/cloud/dialogflowcx_v3/py.typed | 2 - .../dialogflowcx_v3/services/__init__.py | 15 - .../services/agents/__init__.py | 22 - .../services/agents/async_client.py | 1474 -- .../dialogflowcx_v3/services/agents/client.py | 1715 -- .../dialogflowcx_v3/services/agents/pagers.py | 139 - .../services/agents/transports/__init__.py | 38 - .../services/agents/transports/base.py | 321 - .../services/agents/transports/grpc.py | 626 - .../agents/transports/grpc_asyncio.py | 625 - .../services/agents/transports/rest.py | 1743 -- .../services/changelogs/__init__.py | 22 - .../services/changelogs/async_client.py | 672 - .../services/changelogs/client.py | 871 - .../services/changelogs/pagers.py | 139 - .../changelogs/transports/__init__.py | 38 - .../services/changelogs/transports/base.py | 208 - .../services/changelogs/transports/grpc.py | 383 - .../changelogs/transports/grpc_asyncio.py | 382 - .../services/changelogs/transports/rest.py | 839 - .../services/deployments/__init__.py | 22 - .../services/deployments/async_client.py | 689 - .../services/deployments/client.py | 915 - .../services/deployments/pagers.py | 139 - .../deployments/transports/__init__.py | 38 - .../services/deployments/transports/base.py | 208 - .../services/deployments/transports/grpc.py | 385 - .../deployments/transports/grpc_asyncio.py | 384 - .../services/deployments/transports/rest.py | 844 - .../services/entity_types/__init__.py | 22 - .../services/entity_types/async_client.py | 1099 -- .../services/entity_types/client.py | 1298 -- .../services/entity_types/pagers.py | 139 - .../entity_types/transports/__init__.py | 38 - .../services/entity_types/transports/base.py | 252 - .../services/entity_types/transports/grpc.py | 476 - .../entity_types/transports/grpc_asyncio.py | 475 - .../services/entity_types/transports/rest.py | 1271 -- .../services/environments/__init__.py | 22 - .../services/environments/async_client.py | 1542 -- .../services/environments/client.py | 1797 -- .../services/environments/pagers.py | 381 - .../environments/transports/__init__.py | 38 - .../services/environments/transports/base.py | 315 - .../services/environments/transports/grpc.py | 636 - .../environments/transports/grpc_asyncio.py | 635 - .../services/environments/transports/rest.py | 1711 -- .../services/experiments/__init__.py | 22 - .../services/experiments/async_client.py | 1216 -- .../services/experiments/client.py | 1424 -- .../services/experiments/pagers.py | 139 - .../experiments/transports/__init__.py | 38 - .../services/experiments/transports/base.py | 280 - .../services/experiments/transports/grpc.py | 526 - .../experiments/transports/grpc_asyncio.py | 525 - .../services/experiments/transports/rest.py | 1416 -- .../services/flows/__init__.py | 22 - .../services/flows/async_client.py | 1617 -- .../dialogflowcx_v3/services/flows/client.py | 1864 -- .../dialogflowcx_v3/services/flows/pagers.py | 139 - .../services/flows/transports/__init__.py | 38 - .../services/flows/transports/base.py | 329 - .../services/flows/transports/grpc.py | 666 - .../services/flows/transports/grpc_asyncio.py | 665 - .../services/flows/transports/rest.py | 1891 -- .../services/intents/__init__.py | 22 - .../services/intents/async_client.py | 1018 - .../services/intents/client.py | 1226 -- .../services/intents/pagers.py | 139 - .../services/intents/transports/__init__.py | 38 - .../services/intents/transports/base.py | 252 - .../services/intents/transports/grpc.py | 476 - .../intents/transports/grpc_asyncio.py | 475 - .../services/intents/transports/rest.py | 1187 -- .../services/pages/__init__.py | 22 - .../services/pages/async_client.py | 1069 -- .../dialogflowcx_v3/services/pages/client.py | 1313 -- .../dialogflowcx_v3/services/pages/pagers.py | 139 - .../services/pages/transports/__init__.py | 38 - .../services/pages/transports/base.py | 252 - .../services/pages/transports/grpc.py | 474 - .../services/pages/transports/grpc_asyncio.py | 473 - .../services/pages/transports/rest.py | 1228 -- .../security_settings_service/__init__.py | 22 - .../security_settings_service/async_client.py | 1018 - .../security_settings_service/client.py | 1235 -- .../security_settings_service/pagers.py | 139 - .../transports/__init__.py | 38 - .../transports/base.py | 252 - .../transports/grpc.py | 467 - .../transports/grpc_asyncio.py | 466 - .../transports/rest.py | 1183 -- .../services/session_entity_types/__init__.py | 22 - .../session_entity_types/async_client.py | 1064 -- .../services/session_entity_types/client.py | 1263 -- .../services/session_entity_types/pagers.py | 139 - .../transports/__init__.py | 38 - .../session_entity_types/transports/base.py | 252 - .../session_entity_types/transports/grpc.py | 464 - .../transports/grpc_asyncio.py | 463 - .../session_entity_types/transports/rest.py | 1242 -- .../services/sessions/__init__.py | 22 - .../services/sessions/async_client.py | 899 - .../services/sessions/client.py | 1163 -- .../services/sessions/transports/__init__.py | 38 - .../services/sessions/transports/base.py | 242 - .../services/sessions/transports/grpc.py | 458 - .../sessions/transports/grpc_asyncio.py | 457 - .../services/sessions/transports/rest.py | 1003 - .../services/test_cases/__init__.py | 22 - .../services/test_cases/async_client.py | 1737 -- .../services/test_cases/client.py | 2022 -- .../services/test_cases/pagers.py | 260 - .../test_cases/transports/__init__.py | 38 - .../services/test_cases/transports/base.py | 357 - .../services/test_cases/transports/grpc.py | 712 - .../test_cases/transports/grpc_asyncio.py | 711 - .../services/test_cases/transports/rest.py | 2057 -- .../transition_route_groups/__init__.py | 22 - .../transition_route_groups/async_client.py | 1039 - .../transition_route_groups/client.py | 1274 -- .../transition_route_groups/pagers.py | 139 - .../transports/__init__.py | 38 - .../transports/base.py | 252 - .../transports/grpc.py | 481 - .../transports/grpc_asyncio.py | 480 - .../transports/rest.py | 1205 -- .../services/versions/__init__.py | 22 - .../services/versions/async_client.py | 1270 -- .../services/versions/client.py | 1469 -- .../services/versions/pagers.py | 139 - .../services/versions/transports/__init__.py | 38 - .../services/versions/transports/base.py | 287 - .../services/versions/transports/grpc.py | 560 - .../versions/transports/grpc_asyncio.py | 559 - .../services/versions/transports/rest.py | 1468 -- .../services/webhooks/__init__.py | 22 - .../services/webhooks/async_client.py | 1009 - .../services/webhooks/client.py | 1217 -- .../services/webhooks/pagers.py | 139 - .../services/webhooks/transports/__init__.py | 38 - .../services/webhooks/transports/base.py | 252 - .../services/webhooks/transports/grpc.py | 464 - .../webhooks/transports/grpc_asyncio.py | 463 - .../services/webhooks/transports/rest.py | 1187 -- .../cloud/dialogflowcx_v3/types/__init__.py | 479 - .../types/advanced_settings.py | 98 - .../cloud/dialogflowcx_v3/types/agent.py | 737 - .../dialogflowcx_v3/types/audio_config.py | 518 - .../cloud/dialogflowcx_v3/types/changelog.py | 187 - .../cloud/dialogflowcx_v3/types/deployment.py | 217 - .../dialogflowcx_v3/types/entity_type.py | 455 - .../dialogflowcx_v3/types/environment.py | 628 - .../cloud/dialogflowcx_v3/types/experiment.py | 771 - .../cloud/dialogflowcx_v3/types/flow.py | 751 - .../dialogflowcx_v3/types/fulfillment.py | 220 - .../google/cloud/dialogflowcx_v3/types/gcs.py | 51 - .../cloud/dialogflowcx_v3/types/intent.py | 489 - .../cloud/dialogflowcx_v3/types/page.py | 760 - .../dialogflowcx_v3/types/response_message.py | 465 - .../types/security_settings.py | 451 - .../cloud/dialogflowcx_v3/types/session.py | 1571 -- .../types/session_entity_type.py | 280 - .../cloud/dialogflowcx_v3/types/test_case.py | 1420 -- .../types/transition_route_group.py | 320 - .../types/validation_message.py | 162 - .../cloud/dialogflowcx_v3/types/version.py | 383 - .../cloud/dialogflowcx_v3/types/webhook.py | 990 - owl-bot-staging/v3/mypy.ini | 3 - owl-bot-staging/v3/noxfile.py | 184 - ..._v3_generated_agents_create_agent_async.py | 58 - ...w_v3_generated_agents_create_agent_sync.py | 58 - ..._v3_generated_agents_delete_agent_async.py | 50 - ...w_v3_generated_agents_delete_agent_sync.py | 50 - ..._v3_generated_agents_export_agent_async.py | 56 - ...w_v3_generated_agents_export_agent_sync.py | 56 - ...low_v3_generated_agents_get_agent_async.py | 52 - ...flow_v3_generated_agents_get_agent_sync.py | 52 - ...gents_get_agent_validation_result_async.py | 52 - ...agents_get_agent_validation_result_sync.py | 52 - ...w_v3_generated_agents_list_agents_async.py | 53 - ...ow_v3_generated_agents_list_agents_sync.py | 53 - ...v3_generated_agents_restore_agent_async.py | 57 - ..._v3_generated_agents_restore_agent_sync.py | 57 - ..._v3_generated_agents_update_agent_async.py | 57 - ...w_v3_generated_agents_update_agent_sync.py | 57 - ...3_generated_agents_validate_agent_async.py | 52 - ...v3_generated_agents_validate_agent_sync.py | 52 - ...enerated_changelogs_get_changelog_async.py | 52 - ...generated_changelogs_get_changelog_sync.py | 52 - ...erated_changelogs_list_changelogs_async.py | 53 - ...nerated_changelogs_list_changelogs_sync.py | 53 - ...erated_deployments_get_deployment_async.py | 52 - ...nerated_deployments_get_deployment_sync.py | 52 - ...ated_deployments_list_deployments_async.py | 53 - ...rated_deployments_list_deployments_sync.py | 53 - ...d_entity_types_create_entity_type_async.py | 57 - ...ed_entity_types_create_entity_type_sync.py | 57 - ...d_entity_types_delete_entity_type_async.py | 50 - ...ed_entity_types_delete_entity_type_sync.py | 50 - ...ated_entity_types_get_entity_type_async.py | 52 - ...rated_entity_types_get_entity_type_sync.py | 52 - ...ed_entity_types_list_entity_types_async.py | 53 - ...ted_entity_types_list_entity_types_sync.py | 53 - ...d_entity_types_update_entity_type_async.py | 56 - ...ed_entity_types_update_entity_type_sync.py | 56 - ...d_environments_create_environment_async.py | 60 - ...ed_environments_create_environment_sync.py | 60 - ...d_environments_delete_environment_async.py | 50 - ...ed_environments_delete_environment_sync.py | 50 - ...enerated_environments_deploy_flow_async.py | 57 - ...generated_environments_deploy_flow_sync.py | 57 - ...ated_environments_get_environment_async.py | 52 - ...rated_environments_get_environment_sync.py | 52 - ...ents_list_continuous_test_results_async.py | 53 - ...ments_list_continuous_test_results_sync.py | 53 - ...ed_environments_list_environments_async.py | 53 - ...ted_environments_list_environments_sync.py | 53 - ...nments_lookup_environment_history_async.py | 53 - ...onments_lookup_environment_history_sync.py | 53 - ..._environments_run_continuous_test_async.py | 56 - ...d_environments_run_continuous_test_sync.py | 56 - ...d_environments_update_environment_async.py | 59 - ...ed_environments_update_environment_sync.py | 59 - ...ted_experiments_create_experiment_async.py | 56 - ...ated_experiments_create_experiment_sync.py | 56 - ...ted_experiments_delete_experiment_async.py | 50 - ...ated_experiments_delete_experiment_sync.py | 50 - ...erated_experiments_get_experiment_async.py | 52 - ...nerated_experiments_get_experiment_sync.py | 52 - ...ated_experiments_list_experiments_async.py | 53 - ...rated_experiments_list_experiments_sync.py | 53 - ...ated_experiments_start_experiment_async.py | 52 - ...rated_experiments_start_experiment_sync.py | 52 - ...rated_experiments_stop_experiment_async.py | 52 - ...erated_experiments_stop_experiment_sync.py | 52 - ...ted_experiments_update_experiment_async.py | 55 - ...ated_experiments_update_experiment_sync.py | 55 - ...ow_v3_generated_flows_create_flow_async.py | 56 - ...low_v3_generated_flows_create_flow_sync.py | 56 - ...ow_v3_generated_flows_delete_flow_async.py | 50 - ...low_v3_generated_flows_delete_flow_sync.py | 50 - ...ow_v3_generated_flows_export_flow_async.py | 56 - ...low_v3_generated_flows_export_flow_sync.py | 56 - ...gflow_v3_generated_flows_get_flow_async.py | 52 - ...ogflow_v3_generated_flows_get_flow_sync.py | 52 - ..._flows_get_flow_validation_result_async.py | 52 - ...d_flows_get_flow_validation_result_sync.py | 52 - ...ow_v3_generated_flows_import_flow_async.py | 57 - ...low_v3_generated_flows_import_flow_sync.py | 57 - ...low_v3_generated_flows_list_flows_async.py | 53 - ...flow_v3_generated_flows_list_flows_sync.py | 53 - ...low_v3_generated_flows_train_flow_async.py | 56 - ...flow_v3_generated_flows_train_flow_sync.py | 56 - ...ow_v3_generated_flows_update_flow_async.py | 55 - ...low_v3_generated_flows_update_flow_sync.py | 55 - ..._v3_generated_flows_validate_flow_async.py | 52 - ...w_v3_generated_flows_validate_flow_sync.py | 52 - ...3_generated_intents_create_intent_async.py | 56 - ...v3_generated_intents_create_intent_sync.py | 56 - ...3_generated_intents_delete_intent_async.py | 50 - ...v3_generated_intents_delete_intent_sync.py | 50 - ...w_v3_generated_intents_get_intent_async.py | 52 - ...ow_v3_generated_intents_get_intent_sync.py | 52 - ...v3_generated_intents_list_intents_async.py | 53 - ..._v3_generated_intents_list_intents_sync.py | 53 - ...3_generated_intents_update_intent_async.py | 55 - ...v3_generated_intents_update_intent_sync.py | 55 - ...ow_v3_generated_pages_create_page_async.py | 56 - ...low_v3_generated_pages_create_page_sync.py | 56 - ...ow_v3_generated_pages_delete_page_async.py | 50 - ...low_v3_generated_pages_delete_page_sync.py | 50 - ...gflow_v3_generated_pages_get_page_async.py | 52 - ...ogflow_v3_generated_pages_get_page_sync.py | 52 - ...low_v3_generated_pages_list_pages_async.py | 53 - ...flow_v3_generated_pages_list_pages_sync.py | 53 - ...ow_v3_generated_pages_update_page_async.py | 55 - ...low_v3_generated_pages_update_page_sync.py | 55 - ..._service_create_security_settings_async.py | 57 - ...s_service_create_security_settings_sync.py | 57 - ..._service_delete_security_settings_async.py | 50 - ...s_service_delete_security_settings_sync.py | 50 - ...ngs_service_get_security_settings_async.py | 52 - ...ings_service_get_security_settings_sync.py | 52 - ...gs_service_list_security_settings_async.py | 53 - ...ngs_service_list_security_settings_sync.py | 53 - ..._service_update_security_settings_async.py | 56 - ...s_service_update_security_settings_sync.py | 56 - ..._types_create_session_entity_type_async.py | 59 - ...y_types_create_session_entity_type_sync.py | 59 - ..._types_delete_session_entity_type_async.py | 50 - ...y_types_delete_session_entity_type_sync.py | 50 - ...ity_types_get_session_entity_type_async.py | 52 - ...tity_types_get_session_entity_type_sync.py | 52 - ...y_types_list_session_entity_types_async.py | 53 - ...ty_types_list_session_entity_types_sync.py | 53 - ..._types_update_session_entity_type_async.py | 58 - ...y_types_update_session_entity_type_sync.py | 58 - ..._generated_sessions_detect_intent_async.py | 57 - ...3_generated_sessions_detect_intent_sync.py | 57 - ...generated_sessions_fulfill_intent_async.py | 51 - ..._generated_sessions_fulfill_intent_sync.py | 51 - ...3_generated_sessions_match_intent_async.py | 57 - ...v3_generated_sessions_match_intent_sync.py | 57 - ..._sessions_streaming_detect_intent_async.py | 67 - ...d_sessions_streaming_detect_intent_sync.py | 67 - ...est_cases_batch_delete_test_cases_async.py | 51 - ...test_cases_batch_delete_test_cases_sync.py | 51 - ...d_test_cases_batch_run_test_cases_async.py | 57 - ...ed_test_cases_batch_run_test_cases_sync.py | 57 - ...ted_test_cases_calculate_coverage_async.py | 53 - ...ated_test_cases_calculate_coverage_sync.py | 53 - ...rated_test_cases_create_test_case_async.py | 56 - ...erated_test_cases_create_test_case_sync.py | 56 - ...ated_test_cases_export_test_cases_async.py | 57 - ...rated_test_cases_export_test_cases_sync.py | 57 - ...enerated_test_cases_get_test_case_async.py | 52 - ...d_test_cases_get_test_case_result_async.py | 52 - ...ed_test_cases_get_test_case_result_sync.py | 52 - ...generated_test_cases_get_test_case_sync.py | 52 - ...ated_test_cases_import_test_cases_async.py | 57 - ...rated_test_cases_import_test_cases_sync.py | 57 - ...test_cases_list_test_case_results_async.py | 53 - ..._test_cases_list_test_case_results_sync.py | 53 - ...erated_test_cases_list_test_cases_async.py | 53 - ...nerated_test_cases_list_test_cases_sync.py | 53 - ...enerated_test_cases_run_test_case_async.py | 56 - ...generated_test_cases_run_test_case_sync.py | 56 - ...rated_test_cases_update_test_case_async.py | 55 - ...erated_test_cases_update_test_case_sync.py | 55 - ...ups_create_transition_route_group_async.py | 56 - ...oups_create_transition_route_group_sync.py | 56 - ...ups_delete_transition_route_group_async.py | 50 - ...oups_delete_transition_route_group_sync.py | 50 - ...groups_get_transition_route_group_async.py | 52 - ..._groups_get_transition_route_group_sync.py | 52 - ...oups_list_transition_route_groups_async.py | 53 - ...roups_list_transition_route_groups_sync.py | 53 - ...ups_update_transition_route_group_async.py | 55 - ...oups_update_transition_route_group_sync.py | 55 - ...nerated_versions_compare_versions_async.py | 53 - ...enerated_versions_compare_versions_sync.py | 53 - ...generated_versions_create_version_async.py | 60 - ..._generated_versions_create_version_sync.py | 60 - ...generated_versions_delete_version_async.py | 50 - ..._generated_versions_delete_version_sync.py | 50 - ...v3_generated_versions_get_version_async.py | 52 - ..._v3_generated_versions_get_version_sync.py | 52 - ..._generated_versions_list_versions_async.py | 53 - ...3_generated_versions_list_versions_sync.py | 53 - ...3_generated_versions_load_version_async.py | 56 - ...v3_generated_versions_load_version_sync.py | 56 - ...generated_versions_update_version_async.py | 55 - ..._generated_versions_update_version_sync.py | 55 - ...generated_webhooks_create_webhook_async.py | 57 - ..._generated_webhooks_create_webhook_sync.py | 57 - ...generated_webhooks_delete_webhook_async.py | 50 - ..._generated_webhooks_delete_webhook_sync.py | 50 - ...v3_generated_webhooks_get_webhook_async.py | 52 - ..._v3_generated_webhooks_get_webhook_sync.py | 52 - ..._generated_webhooks_list_webhooks_async.py | 53 - ...3_generated_webhooks_list_webhooks_sync.py | 53 - ...generated_webhooks_update_webhook_async.py | 56 - ..._generated_webhooks_update_webhook_sync.py | 56 - ...etadata_google.cloud.dialogflow.cx.v3.json | 15626 ---------------- .../scripts/fixup_dialogflowcx_v3_keywords.py | 272 - owl-bot-staging/v3/setup.py | 90 - .../v3/testing/constraints-3.10.txt | 6 - .../v3/testing/constraints-3.11.txt | 6 - .../v3/testing/constraints-3.12.txt | 6 - .../v3/testing/constraints-3.7.txt | 9 - .../v3/testing/constraints-3.8.txt | 6 - .../v3/testing/constraints-3.9.txt | 6 - owl-bot-staging/v3/tests/__init__.py | 16 - owl-bot-staging/v3/tests/unit/__init__.py | 16 - .../v3/tests/unit/gapic/__init__.py | 16 - .../unit/gapic/dialogflowcx_v3/__init__.py | 16 - .../unit/gapic/dialogflowcx_v3/test_agents.py | 6546 ------- .../gapic/dialogflowcx_v3/test_changelogs.py | 3325 ---- .../gapic/dialogflowcx_v3/test_deployments.py | 3384 ---- .../dialogflowcx_v3/test_entity_types.py | 4808 ----- .../dialogflowcx_v3/test_environments.py | 7010 ------- .../gapic/dialogflowcx_v3/test_experiments.py | 5801 ------ .../unit/gapic/dialogflowcx_v3/test_flows.py | 6882 ------- .../gapic/dialogflowcx_v3/test_intents.py | 4811 ----- .../unit/gapic/dialogflowcx_v3/test_pages.py | 4876 ----- .../test_security_settings_service.py | 4866 ----- .../test_session_entity_types.py | 4733 ----- .../gapic/dialogflowcx_v3/test_sessions.py | 3354 ---- .../gapic/dialogflowcx_v3/test_test_cases.py | 7900 -------- .../test_transition_route_groups.py | 4836 ----- .../gapic/dialogflowcx_v3/test_versions.py | 5748 ------ .../gapic/dialogflowcx_v3/test_webhooks.py | 4774 ----- owl-bot-staging/v3beta1/.coveragerc | 13 - owl-bot-staging/v3beta1/.flake8 | 33 - owl-bot-staging/v3beta1/MANIFEST.in | 2 - owl-bot-staging/v3beta1/README.rst | 49 - owl-bot-staging/v3beta1/docs/conf.py | 376 - .../docs/dialogflowcx_v3beta1/agents.rst | 10 - .../docs/dialogflowcx_v3beta1/changelogs.rst | 10 - .../docs/dialogflowcx_v3beta1/deployments.rst | 10 - .../dialogflowcx_v3beta1/entity_types.rst | 10 - .../dialogflowcx_v3beta1/environments.rst | 10 - .../docs/dialogflowcx_v3beta1/experiments.rst | 10 - .../docs/dialogflowcx_v3beta1/flows.rst | 10 - .../docs/dialogflowcx_v3beta1/intents.rst | 10 - .../docs/dialogflowcx_v3beta1/pages.rst | 10 - .../security_settings_service.rst | 10 - .../docs/dialogflowcx_v3beta1/services.rst | 21 - .../session_entity_types.rst | 10 - .../docs/dialogflowcx_v3beta1/sessions.rst | 6 - .../docs/dialogflowcx_v3beta1/test_cases.rst | 10 - .../transition_route_groups.rst | 10 - .../docs/dialogflowcx_v3beta1/types.rst | 6 - .../docs/dialogflowcx_v3beta1/versions.rst | 10 - .../docs/dialogflowcx_v3beta1/webhooks.rst | 10 - owl-bot-staging/v3beta1/docs/index.rst | 7 - .../google/cloud/dialogflowcx/__init__.py | 505 - .../cloud/dialogflowcx/gapic_version.py | 16 - .../google/cloud/dialogflowcx/py.typed | 2 - .../cloud/dialogflowcx_v3beta1/__init__.py | 506 - .../dialogflowcx_v3beta1/gapic_metadata.json | 1768 -- .../dialogflowcx_v3beta1/gapic_version.py | 16 - .../cloud/dialogflowcx_v3beta1/py.typed | 2 - .../dialogflowcx_v3beta1/services/__init__.py | 15 - .../services/agents/__init__.py | 22 - .../services/agents/async_client.py | 1476 -- .../services/agents/client.py | 1717 -- .../services/agents/pagers.py | 139 - .../services/agents/transports/__init__.py | 38 - .../services/agents/transports/base.py | 321 - .../services/agents/transports/grpc.py | 627 - .../agents/transports/grpc_asyncio.py | 626 - .../services/agents/transports/rest.py | 1747 -- .../services/changelogs/__init__.py | 22 - .../services/changelogs/async_client.py | 672 - .../services/changelogs/client.py | 871 - .../services/changelogs/pagers.py | 139 - .../changelogs/transports/__init__.py | 38 - .../services/changelogs/transports/base.py | 208 - .../services/changelogs/transports/grpc.py | 383 - .../changelogs/transports/grpc_asyncio.py | 382 - .../services/changelogs/transports/rest.py | 839 - .../services/deployments/__init__.py | 22 - .../services/deployments/async_client.py | 689 - .../services/deployments/client.py | 915 - .../services/deployments/pagers.py | 139 - .../deployments/transports/__init__.py | 38 - .../services/deployments/transports/base.py | 208 - .../services/deployments/transports/grpc.py | 385 - .../deployments/transports/grpc_asyncio.py | 384 - .../services/deployments/transports/rest.py | 844 - .../services/entity_types/__init__.py | 22 - .../services/entity_types/async_client.py | 1095 -- .../services/entity_types/client.py | 1294 -- .../services/entity_types/pagers.py | 139 - .../entity_types/transports/__init__.py | 38 - .../services/entity_types/transports/base.py | 252 - .../services/entity_types/transports/grpc.py | 472 - .../entity_types/transports/grpc_asyncio.py | 471 - .../services/entity_types/transports/rest.py | 1271 -- .../services/environments/__init__.py | 22 - .../services/environments/async_client.py | 1542 -- .../services/environments/client.py | 1797 -- .../services/environments/pagers.py | 381 - .../environments/transports/__init__.py | 38 - .../services/environments/transports/base.py | 315 - .../services/environments/transports/grpc.py | 636 - .../environments/transports/grpc_asyncio.py | 635 - .../services/environments/transports/rest.py | 1711 -- .../services/experiments/__init__.py | 22 - .../services/experiments/async_client.py | 1218 -- .../services/experiments/client.py | 1426 -- .../services/experiments/pagers.py | 139 - .../experiments/transports/__init__.py | 38 - .../services/experiments/transports/base.py | 280 - .../services/experiments/transports/grpc.py | 528 - .../experiments/transports/grpc_asyncio.py | 527 - .../services/experiments/transports/rest.py | 1416 -- .../services/flows/__init__.py | 22 - .../services/flows/async_client.py | 1619 -- .../services/flows/client.py | 1866 -- .../services/flows/pagers.py | 139 - .../services/flows/transports/__init__.py | 38 - .../services/flows/transports/base.py | 329 - .../services/flows/transports/grpc.py | 667 - .../services/flows/transports/grpc_asyncio.py | 666 - .../services/flows/transports/rest.py | 1892 -- .../services/intents/__init__.py | 22 - .../services/intents/async_client.py | 1018 - .../services/intents/client.py | 1226 -- .../services/intents/pagers.py | 139 - .../services/intents/transports/__init__.py | 38 - .../services/intents/transports/base.py | 252 - .../services/intents/transports/grpc.py | 476 - .../intents/transports/grpc_asyncio.py | 475 - .../services/intents/transports/rest.py | 1187 -- .../services/pages/__init__.py | 22 - .../services/pages/async_client.py | 1059 -- .../services/pages/client.py | 1303 -- .../services/pages/pagers.py | 139 - .../services/pages/transports/__init__.py | 38 - .../services/pages/transports/base.py | 252 - .../services/pages/transports/grpc.py | 463 - .../services/pages/transports/grpc_asyncio.py | 462 - .../services/pages/transports/rest.py | 1229 -- .../security_settings_service/__init__.py | 22 - .../security_settings_service/async_client.py | 1018 - .../security_settings_service/client.py | 1235 -- .../security_settings_service/pagers.py | 139 - .../transports/__init__.py | 38 - .../transports/base.py | 252 - .../transports/grpc.py | 467 - .../transports/grpc_asyncio.py | 466 - .../transports/rest.py | 1183 -- .../services/session_entity_types/__init__.py | 22 - .../session_entity_types/async_client.py | 1067 -- .../services/session_entity_types/client.py | 1266 -- .../services/session_entity_types/pagers.py | 139 - .../transports/__init__.py | 38 - .../session_entity_types/transports/base.py | 252 - .../session_entity_types/transports/grpc.py | 464 - .../transports/grpc_asyncio.py | 463 - .../session_entity_types/transports/rest.py | 1242 -- .../services/sessions/__init__.py | 22 - .../services/sessions/async_client.py | 899 - .../services/sessions/client.py | 1163 -- .../services/sessions/transports/__init__.py | 38 - .../services/sessions/transports/base.py | 242 - .../services/sessions/transports/grpc.py | 458 - .../sessions/transports/grpc_asyncio.py | 457 - .../services/sessions/transports/rest.py | 1003 - .../services/test_cases/__init__.py | 22 - .../services/test_cases/async_client.py | 1737 -- .../services/test_cases/client.py | 2022 -- .../services/test_cases/pagers.py | 260 - .../test_cases/transports/__init__.py | 38 - .../services/test_cases/transports/base.py | 357 - .../services/test_cases/transports/grpc.py | 712 - .../test_cases/transports/grpc_asyncio.py | 711 - .../services/test_cases/transports/rest.py | 2057 -- .../transition_route_groups/__init__.py | 22 - .../transition_route_groups/async_client.py | 1039 - .../transition_route_groups/client.py | 1274 -- .../transition_route_groups/pagers.py | 139 - .../transports/__init__.py | 38 - .../transports/base.py | 252 - .../transports/grpc.py | 481 - .../transports/grpc_asyncio.py | 480 - .../transports/rest.py | 1205 -- .../services/versions/__init__.py | 22 - .../services/versions/async_client.py | 1273 -- .../services/versions/client.py | 1472 -- .../services/versions/pagers.py | 139 - .../services/versions/transports/__init__.py | 38 - .../services/versions/transports/base.py | 287 - .../services/versions/transports/grpc.py | 561 - .../versions/transports/grpc_asyncio.py | 560 - .../services/versions/transports/rest.py | 1468 -- .../services/webhooks/__init__.py | 22 - .../services/webhooks/async_client.py | 1009 - .../services/webhooks/client.py | 1217 -- .../services/webhooks/pagers.py | 139 - .../services/webhooks/transports/__init__.py | 38 - .../services/webhooks/transports/base.py | 252 - .../services/webhooks/transports/grpc.py | 464 - .../webhooks/transports/grpc_asyncio.py | 463 - .../services/webhooks/transports/rest.py | 1187 -- .../dialogflowcx_v3beta1/types/__init__.py | 479 - .../types/advanced_settings.py | 98 - .../cloud/dialogflowcx_v3beta1/types/agent.py | 737 - .../types/audio_config.py | 520 - .../dialogflowcx_v3beta1/types/changelog.py | 187 - .../dialogflowcx_v3beta1/types/deployment.py | 217 - .../dialogflowcx_v3beta1/types/entity_type.py | 455 - .../dialogflowcx_v3beta1/types/environment.py | 628 - .../dialogflowcx_v3beta1/types/experiment.py | 773 - .../cloud/dialogflowcx_v3beta1/types/flow.py | 752 - .../dialogflowcx_v3beta1/types/fulfillment.py | 220 - .../cloud/dialogflowcx_v3beta1/types/gcs.py | 51 - .../types/import_strategy.py | 63 - .../dialogflowcx_v3beta1/types/intent.py | 489 - .../cloud/dialogflowcx_v3beta1/types/page.py | 760 - .../types/response_message.py | 434 - .../types/security_settings.py | 454 - .../dialogflowcx_v3beta1/types/session.py | 1576 -- .../types/session_entity_type.py | 280 - .../dialogflowcx_v3beta1/types/test_case.py | 1422 -- .../types/transition_route_group.py | 322 - .../types/validation_message.py | 162 - .../dialogflowcx_v3beta1/types/version.py | 386 - .../dialogflowcx_v3beta1/types/webhook.py | 992 - owl-bot-staging/v3beta1/mypy.ini | 3 - owl-bot-staging/v3beta1/noxfile.py | 184 - ...ta1_generated_agents_create_agent_async.py | 58 - ...eta1_generated_agents_create_agent_sync.py | 58 - ...ta1_generated_agents_delete_agent_async.py | 50 - ...eta1_generated_agents_delete_agent_sync.py | 50 - ...ta1_generated_agents_export_agent_async.py | 56 - ...eta1_generated_agents_export_agent_sync.py | 56 - ...3beta1_generated_agents_get_agent_async.py | 52 - ...v3beta1_generated_agents_get_agent_sync.py | 52 - ...gents_get_agent_validation_result_async.py | 52 - ...agents_get_agent_validation_result_sync.py | 52 - ...eta1_generated_agents_list_agents_async.py | 53 - ...beta1_generated_agents_list_agents_sync.py | 53 - ...a1_generated_agents_restore_agent_async.py | 57 - ...ta1_generated_agents_restore_agent_sync.py | 57 - ...ta1_generated_agents_update_agent_async.py | 57 - ...eta1_generated_agents_update_agent_sync.py | 57 - ...1_generated_agents_validate_agent_async.py | 52 - ...a1_generated_agents_validate_agent_sync.py | 52 - ...enerated_changelogs_get_changelog_async.py | 52 - ...generated_changelogs_get_changelog_sync.py | 52 - ...erated_changelogs_list_changelogs_async.py | 53 - ...nerated_changelogs_list_changelogs_sync.py | 53 - ...erated_deployments_get_deployment_async.py | 52 - ...nerated_deployments_get_deployment_sync.py | 52 - ...ated_deployments_list_deployments_async.py | 53 - ...rated_deployments_list_deployments_sync.py | 53 - ...d_entity_types_create_entity_type_async.py | 57 - ...ed_entity_types_create_entity_type_sync.py | 57 - ...d_entity_types_delete_entity_type_async.py | 50 - ...ed_entity_types_delete_entity_type_sync.py | 50 - ...ated_entity_types_get_entity_type_async.py | 52 - ...rated_entity_types_get_entity_type_sync.py | 52 - ...ed_entity_types_list_entity_types_async.py | 53 - ...ted_entity_types_list_entity_types_sync.py | 53 - ...d_entity_types_update_entity_type_async.py | 56 - ...ed_entity_types_update_entity_type_sync.py | 56 - ...d_environments_create_environment_async.py | 60 - ...ed_environments_create_environment_sync.py | 60 - ...d_environments_delete_environment_async.py | 50 - ...ed_environments_delete_environment_sync.py | 50 - ...enerated_environments_deploy_flow_async.py | 57 - ...generated_environments_deploy_flow_sync.py | 57 - ...ated_environments_get_environment_async.py | 52 - ...rated_environments_get_environment_sync.py | 52 - ...ents_list_continuous_test_results_async.py | 53 - ...ments_list_continuous_test_results_sync.py | 53 - ...ed_environments_list_environments_async.py | 53 - ...ted_environments_list_environments_sync.py | 53 - ...nments_lookup_environment_history_async.py | 53 - ...onments_lookup_environment_history_sync.py | 53 - ..._environments_run_continuous_test_async.py | 56 - ...d_environments_run_continuous_test_sync.py | 56 - ...d_environments_update_environment_async.py | 59 - ...ed_environments_update_environment_sync.py | 59 - ...ted_experiments_create_experiment_async.py | 56 - ...ated_experiments_create_experiment_sync.py | 56 - ...ted_experiments_delete_experiment_async.py | 50 - ...ated_experiments_delete_experiment_sync.py | 50 - ...erated_experiments_get_experiment_async.py | 52 - ...nerated_experiments_get_experiment_sync.py | 52 - ...ated_experiments_list_experiments_async.py | 53 - ...rated_experiments_list_experiments_sync.py | 53 - ...ated_experiments_start_experiment_async.py | 52 - ...rated_experiments_start_experiment_sync.py | 52 - ...rated_experiments_stop_experiment_async.py | 52 - ...erated_experiments_stop_experiment_sync.py | 52 - ...ted_experiments_update_experiment_async.py | 55 - ...ated_experiments_update_experiment_sync.py | 55 - ...beta1_generated_flows_create_flow_async.py | 56 - ...3beta1_generated_flows_create_flow_sync.py | 56 - ...beta1_generated_flows_delete_flow_async.py | 50 - ...3beta1_generated_flows_delete_flow_sync.py | 50 - ...beta1_generated_flows_export_flow_async.py | 56 - ...3beta1_generated_flows_export_flow_sync.py | 56 - ..._v3beta1_generated_flows_get_flow_async.py | 52 - ...w_v3beta1_generated_flows_get_flow_sync.py | 52 - ..._flows_get_flow_validation_result_async.py | 52 - ...d_flows_get_flow_validation_result_sync.py | 52 - ...beta1_generated_flows_import_flow_async.py | 57 - ...3beta1_generated_flows_import_flow_sync.py | 57 - ...3beta1_generated_flows_list_flows_async.py | 53 - ...v3beta1_generated_flows_list_flows_sync.py | 53 - ...3beta1_generated_flows_train_flow_async.py | 56 - ...v3beta1_generated_flows_train_flow_sync.py | 56 - ...beta1_generated_flows_update_flow_async.py | 55 - ...3beta1_generated_flows_update_flow_sync.py | 55 - ...ta1_generated_flows_validate_flow_async.py | 52 - ...eta1_generated_flows_validate_flow_sync.py | 52 - ...1_generated_intents_create_intent_async.py | 56 - ...a1_generated_intents_create_intent_sync.py | 56 - ...1_generated_intents_delete_intent_async.py | 50 - ...a1_generated_intents_delete_intent_sync.py | 50 - ...eta1_generated_intents_get_intent_async.py | 52 - ...beta1_generated_intents_get_intent_sync.py | 52 - ...a1_generated_intents_list_intents_async.py | 53 - ...ta1_generated_intents_list_intents_sync.py | 53 - ...1_generated_intents_update_intent_async.py | 55 - ...a1_generated_intents_update_intent_sync.py | 55 - ...beta1_generated_pages_create_page_async.py | 56 - ...3beta1_generated_pages_create_page_sync.py | 56 - ...beta1_generated_pages_delete_page_async.py | 50 - ...3beta1_generated_pages_delete_page_sync.py | 50 - ..._v3beta1_generated_pages_get_page_async.py | 52 - ...w_v3beta1_generated_pages_get_page_sync.py | 52 - ...3beta1_generated_pages_list_pages_async.py | 53 - ...v3beta1_generated_pages_list_pages_sync.py | 53 - ...beta1_generated_pages_update_page_async.py | 55 - ...3beta1_generated_pages_update_page_sync.py | 55 - ..._service_create_security_settings_async.py | 57 - ...s_service_create_security_settings_sync.py | 57 - ..._service_delete_security_settings_async.py | 50 - ...s_service_delete_security_settings_sync.py | 50 - ...ngs_service_get_security_settings_async.py | 52 - ...ings_service_get_security_settings_sync.py | 52 - ...gs_service_list_security_settings_async.py | 53 - ...ngs_service_list_security_settings_sync.py | 53 - ..._service_update_security_settings_async.py | 56 - ...s_service_update_security_settings_sync.py | 56 - ..._types_create_session_entity_type_async.py | 59 - ...y_types_create_session_entity_type_sync.py | 59 - ..._types_delete_session_entity_type_async.py | 50 - ...y_types_delete_session_entity_type_sync.py | 50 - ...ity_types_get_session_entity_type_async.py | 52 - ...tity_types_get_session_entity_type_sync.py | 52 - ...y_types_list_session_entity_types_async.py | 53 - ...ty_types_list_session_entity_types_sync.py | 53 - ..._types_update_session_entity_type_async.py | 58 - ...y_types_update_session_entity_type_sync.py | 58 - ..._generated_sessions_detect_intent_async.py | 57 - ...1_generated_sessions_detect_intent_sync.py | 57 - ...generated_sessions_fulfill_intent_async.py | 51 - ..._generated_sessions_fulfill_intent_sync.py | 51 - ...1_generated_sessions_match_intent_async.py | 57 - ...a1_generated_sessions_match_intent_sync.py | 57 - ..._sessions_streaming_detect_intent_async.py | 67 - ...d_sessions_streaming_detect_intent_sync.py | 67 - ...est_cases_batch_delete_test_cases_async.py | 51 - ...test_cases_batch_delete_test_cases_sync.py | 51 - ...d_test_cases_batch_run_test_cases_async.py | 57 - ...ed_test_cases_batch_run_test_cases_sync.py | 57 - ...ted_test_cases_calculate_coverage_async.py | 53 - ...ated_test_cases_calculate_coverage_sync.py | 53 - ...rated_test_cases_create_test_case_async.py | 56 - ...erated_test_cases_create_test_case_sync.py | 56 - ...ated_test_cases_export_test_cases_async.py | 57 - ...rated_test_cases_export_test_cases_sync.py | 57 - ...enerated_test_cases_get_test_case_async.py | 52 - ...d_test_cases_get_test_case_result_async.py | 52 - ...ed_test_cases_get_test_case_result_sync.py | 52 - ...generated_test_cases_get_test_case_sync.py | 52 - ...ated_test_cases_import_test_cases_async.py | 57 - ...rated_test_cases_import_test_cases_sync.py | 57 - ...test_cases_list_test_case_results_async.py | 53 - ..._test_cases_list_test_case_results_sync.py | 53 - ...erated_test_cases_list_test_cases_async.py | 53 - ...nerated_test_cases_list_test_cases_sync.py | 53 - ...enerated_test_cases_run_test_case_async.py | 56 - ...generated_test_cases_run_test_case_sync.py | 56 - ...rated_test_cases_update_test_case_async.py | 55 - ...erated_test_cases_update_test_case_sync.py | 55 - ...ups_create_transition_route_group_async.py | 56 - ...oups_create_transition_route_group_sync.py | 56 - ...ups_delete_transition_route_group_async.py | 50 - ...oups_delete_transition_route_group_sync.py | 50 - ...groups_get_transition_route_group_async.py | 52 - ..._groups_get_transition_route_group_sync.py | 52 - ...oups_list_transition_route_groups_async.py | 53 - ...roups_list_transition_route_groups_sync.py | 53 - ...ups_update_transition_route_group_async.py | 55 - ...oups_update_transition_route_group_sync.py | 55 - ...nerated_versions_compare_versions_async.py | 53 - ...enerated_versions_compare_versions_sync.py | 53 - ...generated_versions_create_version_async.py | 60 - ..._generated_versions_create_version_sync.py | 60 - ...generated_versions_delete_version_async.py | 50 - ..._generated_versions_delete_version_sync.py | 50 - ...a1_generated_versions_get_version_async.py | 52 - ...ta1_generated_versions_get_version_sync.py | 52 - ..._generated_versions_list_versions_async.py | 53 - ...1_generated_versions_list_versions_sync.py | 53 - ...1_generated_versions_load_version_async.py | 56 - ...a1_generated_versions_load_version_sync.py | 56 - ...generated_versions_update_version_async.py | 55 - ..._generated_versions_update_version_sync.py | 55 - ...generated_webhooks_create_webhook_async.py | 57 - ..._generated_webhooks_create_webhook_sync.py | 57 - ...generated_webhooks_delete_webhook_async.py | 50 - ..._generated_webhooks_delete_webhook_sync.py | 50 - ...a1_generated_webhooks_get_webhook_async.py | 52 - ...ta1_generated_webhooks_get_webhook_sync.py | 52 - ..._generated_webhooks_list_webhooks_async.py | 53 - ...1_generated_webhooks_list_webhooks_sync.py | 53 - ...generated_webhooks_update_webhook_async.py | 56 - ..._generated_webhooks_update_webhook_sync.py | 56 - ...ta_google.cloud.dialogflow.cx.v3beta1.json | 15626 ---------------- .../fixup_dialogflowcx_v3beta1_keywords.py | 272 - owl-bot-staging/v3beta1/setup.py | 90 - .../v3beta1/testing/constraints-3.10.txt | 6 - .../v3beta1/testing/constraints-3.11.txt | 6 - .../v3beta1/testing/constraints-3.12.txt | 6 - .../v3beta1/testing/constraints-3.7.txt | 9 - .../v3beta1/testing/constraints-3.8.txt | 6 - .../v3beta1/testing/constraints-3.9.txt | 6 - owl-bot-staging/v3beta1/tests/__init__.py | 16 - .../v3beta1/tests/unit/__init__.py | 16 - .../v3beta1/tests/unit/gapic/__init__.py | 16 - .../gapic/dialogflowcx_v3beta1/__init__.py | 16 - .../gapic/dialogflowcx_v3beta1/test_agents.py | 6546 ------- .../dialogflowcx_v3beta1/test_changelogs.py | 3325 ---- .../dialogflowcx_v3beta1/test_deployments.py | 3384 ---- .../dialogflowcx_v3beta1/test_entity_types.py | 4808 ----- .../dialogflowcx_v3beta1/test_environments.py | 7010 ------- .../dialogflowcx_v3beta1/test_experiments.py | 5801 ------ .../gapic/dialogflowcx_v3beta1/test_flows.py | 6882 ------- .../dialogflowcx_v3beta1/test_intents.py | 4811 ----- .../gapic/dialogflowcx_v3beta1/test_pages.py | 4876 ----- .../test_security_settings_service.py | 4866 ----- .../test_session_entity_types.py | 4733 ----- .../dialogflowcx_v3beta1/test_sessions.py | 3354 ---- .../dialogflowcx_v3beta1/test_test_cases.py | 7900 -------- .../test_transition_route_groups.py | 4836 ----- .../dialogflowcx_v3beta1/test_versions.py | 5748 ------ .../dialogflowcx_v3beta1/test_webhooks.py | 4774 ----- scripts/fixup_dialogflowcx_v3_keywords.py | 2 +- .../unit/gapic/dialogflowcx_v3/test_flows.py | 5 + .../unit/gapic/dialogflowcx_v3/test_pages.py | 4 + .../gapic/dialogflowcx_v3/test_test_cases.py | 4 + .../test_transition_route_groups.py | 4 + 868 files changed, 203 insertions(+), 425054 deletions(-) rename {owl-bot-staging/v3/google => google}/cloud/dialogflowcx_v3/types/import_strategy.py (96%) delete mode 100644 owl-bot-staging/v3/.coveragerc delete mode 100644 owl-bot-staging/v3/.flake8 delete mode 100644 owl-bot-staging/v3/MANIFEST.in delete mode 100644 owl-bot-staging/v3/README.rst delete mode 100644 owl-bot-staging/v3/docs/conf.py delete mode 100644 owl-bot-staging/v3/docs/dialogflowcx_v3/agents.rst delete mode 100644 owl-bot-staging/v3/docs/dialogflowcx_v3/changelogs.rst delete mode 100644 owl-bot-staging/v3/docs/dialogflowcx_v3/deployments.rst delete mode 100644 owl-bot-staging/v3/docs/dialogflowcx_v3/entity_types.rst delete mode 100644 owl-bot-staging/v3/docs/dialogflowcx_v3/environments.rst delete mode 100644 owl-bot-staging/v3/docs/dialogflowcx_v3/experiments.rst delete mode 100644 owl-bot-staging/v3/docs/dialogflowcx_v3/flows.rst delete mode 100644 owl-bot-staging/v3/docs/dialogflowcx_v3/intents.rst delete mode 100644 owl-bot-staging/v3/docs/dialogflowcx_v3/pages.rst delete mode 100644 owl-bot-staging/v3/docs/dialogflowcx_v3/security_settings_service.rst delete mode 100644 owl-bot-staging/v3/docs/dialogflowcx_v3/services.rst delete mode 100644 owl-bot-staging/v3/docs/dialogflowcx_v3/session_entity_types.rst delete mode 100644 owl-bot-staging/v3/docs/dialogflowcx_v3/sessions.rst delete mode 100644 owl-bot-staging/v3/docs/dialogflowcx_v3/test_cases.rst delete mode 100644 owl-bot-staging/v3/docs/dialogflowcx_v3/transition_route_groups.rst delete mode 100644 owl-bot-staging/v3/docs/dialogflowcx_v3/types.rst delete mode 100644 owl-bot-staging/v3/docs/dialogflowcx_v3/versions.rst delete mode 100644 owl-bot-staging/v3/docs/dialogflowcx_v3/webhooks.rst delete mode 100644 owl-bot-staging/v3/docs/index.rst delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx/gapic_version.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx/py.typed delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/gapic_metadata.json delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/gapic_version.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/py.typed delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/async_client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/pagers.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/transports/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/transports/base.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/transports/grpc.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/transports/rest.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/async_client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/pagers.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/transports/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/transports/base.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/transports/grpc.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/transports/rest.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/async_client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/pagers.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/transports/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/transports/base.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/transports/grpc.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/transports/rest.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/async_client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/pagers.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/transports/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/transports/base.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/transports/rest.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/async_client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/pagers.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/transports/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/transports/base.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/transports/grpc.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/transports/rest.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/async_client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/pagers.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/transports/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/transports/base.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/transports/rest.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/async_client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/pagers.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/transports/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/transports/base.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/transports/grpc.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/transports/rest.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/async_client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/pagers.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/transports/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/transports/base.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/transports/grpc.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/transports/rest.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/async_client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/pagers.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/transports/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/transports/base.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/transports/grpc.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/transports/rest.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/async_client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/pagers.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/base.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/grpc.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/rest.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/async_client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/pagers.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/base.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/grpc.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/rest.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/async_client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/transports/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/transports/base.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/transports/rest.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/async_client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/pagers.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/transports/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/transports/base.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/transports/grpc.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/transports/rest.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/async_client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/pagers.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/base.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/grpc.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/rest.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/async_client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/pagers.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/transports/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/transports/base.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/transports/grpc.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/transports/rest.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/async_client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/client.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/pagers.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/transports/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/transports/base.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/transports/rest.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/__init__.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/advanced_settings.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/agent.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/audio_config.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/changelog.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/deployment.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/entity_type.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/environment.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/experiment.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/flow.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/fulfillment.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/gcs.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/intent.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/page.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/response_message.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/security_settings.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/session.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/session_entity_type.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/test_case.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/transition_route_group.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/validation_message.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/version.py delete mode 100644 owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/webhook.py delete mode 100644 owl-bot-staging/v3/mypy.ini delete mode 100644 owl-bot-staging/v3/noxfile.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_agents_create_agent_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_agents_create_agent_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_agents_delete_agent_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_agents_delete_agent_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_agents_export_agent_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_agents_export_agent_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_agents_get_agent_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_agents_get_agent_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_agents_get_agent_validation_result_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_agents_get_agent_validation_result_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_agents_list_agents_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_agents_list_agents_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_agents_restore_agent_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_agents_restore_agent_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_agents_update_agent_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_agents_update_agent_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_agents_validate_agent_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_agents_validate_agent_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_changelogs_get_changelog_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_changelogs_get_changelog_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_changelogs_list_changelogs_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_changelogs_list_changelogs_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_deployments_get_deployment_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_deployments_get_deployment_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_deployments_list_deployments_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_deployments_list_deployments_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_entity_types_create_entity_type_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_entity_types_create_entity_type_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_entity_types_delete_entity_type_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_entity_types_delete_entity_type_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_entity_types_get_entity_type_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_entity_types_get_entity_type_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_entity_types_list_entity_types_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_entity_types_list_entity_types_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_entity_types_update_entity_type_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_entity_types_update_entity_type_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_environments_create_environment_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_environments_create_environment_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_environments_delete_environment_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_environments_delete_environment_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_environments_deploy_flow_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_environments_deploy_flow_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_environments_get_environment_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_environments_get_environment_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_environments_list_continuous_test_results_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_environments_list_continuous_test_results_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_environments_list_environments_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_environments_list_environments_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_environments_lookup_environment_history_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_environments_lookup_environment_history_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_environments_run_continuous_test_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_environments_run_continuous_test_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_environments_update_environment_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_environments_update_environment_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_experiments_create_experiment_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_experiments_create_experiment_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_experiments_delete_experiment_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_experiments_delete_experiment_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_experiments_get_experiment_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_experiments_get_experiment_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_experiments_list_experiments_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_experiments_list_experiments_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_experiments_start_experiment_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_experiments_start_experiment_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_experiments_stop_experiment_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_experiments_stop_experiment_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_experiments_update_experiment_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_experiments_update_experiment_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_flows_create_flow_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_flows_create_flow_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_flows_delete_flow_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_flows_delete_flow_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_flows_export_flow_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_flows_export_flow_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_flows_get_flow_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_flows_get_flow_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_flows_get_flow_validation_result_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_flows_get_flow_validation_result_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_flows_import_flow_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_flows_import_flow_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_flows_list_flows_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_flows_list_flows_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_flows_train_flow_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_flows_train_flow_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_flows_update_flow_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_flows_update_flow_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_flows_validate_flow_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_flows_validate_flow_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_intents_create_intent_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_intents_create_intent_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_intents_delete_intent_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_intents_delete_intent_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_intents_get_intent_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_intents_get_intent_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_intents_list_intents_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_intents_list_intents_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_intents_update_intent_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_intents_update_intent_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_pages_create_page_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_pages_create_page_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_pages_delete_page_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_pages_delete_page_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_pages_get_page_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_pages_get_page_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_pages_list_pages_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_pages_list_pages_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_pages_update_page_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_pages_update_page_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_security_settings_service_create_security_settings_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_security_settings_service_create_security_settings_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_security_settings_service_delete_security_settings_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_security_settings_service_delete_security_settings_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_security_settings_service_get_security_settings_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_security_settings_service_get_security_settings_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_security_settings_service_list_security_settings_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_security_settings_service_list_security_settings_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_security_settings_service_update_security_settings_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_security_settings_service_update_security_settings_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_session_entity_types_create_session_entity_type_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_session_entity_types_create_session_entity_type_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_session_entity_types_delete_session_entity_type_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_session_entity_types_delete_session_entity_type_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_session_entity_types_get_session_entity_type_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_session_entity_types_get_session_entity_type_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_session_entity_types_list_session_entity_types_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_session_entity_types_list_session_entity_types_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_session_entity_types_update_session_entity_type_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_session_entity_types_update_session_entity_type_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_sessions_detect_intent_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_sessions_detect_intent_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_sessions_fulfill_intent_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_sessions_fulfill_intent_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_sessions_match_intent_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_sessions_match_intent_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_sessions_streaming_detect_intent_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_sessions_streaming_detect_intent_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_batch_delete_test_cases_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_batch_delete_test_cases_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_batch_run_test_cases_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_batch_run_test_cases_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_calculate_coverage_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_calculate_coverage_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_create_test_case_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_create_test_case_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_export_test_cases_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_export_test_cases_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_get_test_case_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_get_test_case_result_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_get_test_case_result_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_get_test_case_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_import_test_cases_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_import_test_cases_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_list_test_case_results_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_list_test_case_results_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_list_test_cases_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_list_test_cases_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_run_test_case_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_run_test_case_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_update_test_case_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_test_cases_update_test_case_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_create_transition_route_group_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_create_transition_route_group_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_delete_transition_route_group_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_delete_transition_route_group_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_get_transition_route_group_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_get_transition_route_group_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_list_transition_route_groups_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_list_transition_route_groups_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_update_transition_route_group_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_update_transition_route_group_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_versions_compare_versions_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_versions_compare_versions_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_versions_create_version_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_versions_create_version_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_versions_delete_version_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_versions_delete_version_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_versions_get_version_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_versions_get_version_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_versions_list_versions_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_versions_list_versions_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_versions_load_version_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_versions_load_version_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_versions_update_version_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_versions_update_version_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_webhooks_create_webhook_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_webhooks_create_webhook_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_webhooks_delete_webhook_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_webhooks_delete_webhook_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_webhooks_get_webhook_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_webhooks_get_webhook_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_webhooks_list_webhooks_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_webhooks_list_webhooks_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_webhooks_update_webhook_async.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/dialogflow_v3_generated_webhooks_update_webhook_sync.py delete mode 100644 owl-bot-staging/v3/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.cx.v3.json delete mode 100644 owl-bot-staging/v3/scripts/fixup_dialogflowcx_v3_keywords.py delete mode 100644 owl-bot-staging/v3/setup.py delete mode 100644 owl-bot-staging/v3/testing/constraints-3.10.txt delete mode 100644 owl-bot-staging/v3/testing/constraints-3.11.txt delete mode 100644 owl-bot-staging/v3/testing/constraints-3.12.txt delete mode 100644 owl-bot-staging/v3/testing/constraints-3.7.txt delete mode 100644 owl-bot-staging/v3/testing/constraints-3.8.txt delete mode 100644 owl-bot-staging/v3/testing/constraints-3.9.txt delete mode 100644 owl-bot-staging/v3/tests/__init__.py delete mode 100644 owl-bot-staging/v3/tests/unit/__init__.py delete mode 100644 owl-bot-staging/v3/tests/unit/gapic/__init__.py delete mode 100644 owl-bot-staging/v3/tests/unit/gapic/dialogflowcx_v3/__init__.py delete mode 100644 owl-bot-staging/v3/tests/unit/gapic/dialogflowcx_v3/test_agents.py delete mode 100644 owl-bot-staging/v3/tests/unit/gapic/dialogflowcx_v3/test_changelogs.py delete mode 100644 owl-bot-staging/v3/tests/unit/gapic/dialogflowcx_v3/test_deployments.py delete mode 100644 owl-bot-staging/v3/tests/unit/gapic/dialogflowcx_v3/test_entity_types.py delete mode 100644 owl-bot-staging/v3/tests/unit/gapic/dialogflowcx_v3/test_environments.py delete mode 100644 owl-bot-staging/v3/tests/unit/gapic/dialogflowcx_v3/test_experiments.py delete mode 100644 owl-bot-staging/v3/tests/unit/gapic/dialogflowcx_v3/test_flows.py delete mode 100644 owl-bot-staging/v3/tests/unit/gapic/dialogflowcx_v3/test_intents.py delete mode 100644 owl-bot-staging/v3/tests/unit/gapic/dialogflowcx_v3/test_pages.py delete mode 100644 owl-bot-staging/v3/tests/unit/gapic/dialogflowcx_v3/test_security_settings_service.py delete mode 100644 owl-bot-staging/v3/tests/unit/gapic/dialogflowcx_v3/test_session_entity_types.py delete mode 100644 owl-bot-staging/v3/tests/unit/gapic/dialogflowcx_v3/test_sessions.py delete mode 100644 owl-bot-staging/v3/tests/unit/gapic/dialogflowcx_v3/test_test_cases.py delete mode 100644 owl-bot-staging/v3/tests/unit/gapic/dialogflowcx_v3/test_transition_route_groups.py delete mode 100644 owl-bot-staging/v3/tests/unit/gapic/dialogflowcx_v3/test_versions.py delete mode 100644 owl-bot-staging/v3/tests/unit/gapic/dialogflowcx_v3/test_webhooks.py delete mode 100644 owl-bot-staging/v3beta1/.coveragerc delete mode 100644 owl-bot-staging/v3beta1/.flake8 delete mode 100644 owl-bot-staging/v3beta1/MANIFEST.in delete mode 100644 owl-bot-staging/v3beta1/README.rst delete mode 100644 owl-bot-staging/v3beta1/docs/conf.py delete mode 100644 owl-bot-staging/v3beta1/docs/dialogflowcx_v3beta1/agents.rst delete mode 100644 owl-bot-staging/v3beta1/docs/dialogflowcx_v3beta1/changelogs.rst delete mode 100644 owl-bot-staging/v3beta1/docs/dialogflowcx_v3beta1/deployments.rst delete mode 100644 owl-bot-staging/v3beta1/docs/dialogflowcx_v3beta1/entity_types.rst delete mode 100644 owl-bot-staging/v3beta1/docs/dialogflowcx_v3beta1/environments.rst delete mode 100644 owl-bot-staging/v3beta1/docs/dialogflowcx_v3beta1/experiments.rst delete mode 100644 owl-bot-staging/v3beta1/docs/dialogflowcx_v3beta1/flows.rst delete mode 100644 owl-bot-staging/v3beta1/docs/dialogflowcx_v3beta1/intents.rst delete mode 100644 owl-bot-staging/v3beta1/docs/dialogflowcx_v3beta1/pages.rst delete mode 100644 owl-bot-staging/v3beta1/docs/dialogflowcx_v3beta1/security_settings_service.rst delete mode 100644 owl-bot-staging/v3beta1/docs/dialogflowcx_v3beta1/services.rst delete mode 100644 owl-bot-staging/v3beta1/docs/dialogflowcx_v3beta1/session_entity_types.rst delete mode 100644 owl-bot-staging/v3beta1/docs/dialogflowcx_v3beta1/sessions.rst delete mode 100644 owl-bot-staging/v3beta1/docs/dialogflowcx_v3beta1/test_cases.rst delete mode 100644 owl-bot-staging/v3beta1/docs/dialogflowcx_v3beta1/transition_route_groups.rst delete mode 100644 owl-bot-staging/v3beta1/docs/dialogflowcx_v3beta1/types.rst delete mode 100644 owl-bot-staging/v3beta1/docs/dialogflowcx_v3beta1/versions.rst delete mode 100644 owl-bot-staging/v3beta1/docs/dialogflowcx_v3beta1/webhooks.rst delete mode 100644 owl-bot-staging/v3beta1/docs/index.rst delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx/gapic_version.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx/py.typed delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/gapic_version.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/py.typed delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/agents/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/agents/async_client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/agents/client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/agents/pagers.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/agents/transports/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/agents/transports/base.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/agents/transports/grpc.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/agents/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/agents/transports/rest.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/changelogs/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/changelogs/async_client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/changelogs/client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/changelogs/pagers.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/changelogs/transports/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/changelogs/transports/base.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/changelogs/transports/grpc.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/changelogs/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/changelogs/transports/rest.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/deployments/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/deployments/async_client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/deployments/client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/deployments/pagers.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/deployments/transports/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/deployments/transports/base.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/deployments/transports/grpc.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/deployments/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/deployments/transports/rest.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/entity_types/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/entity_types/async_client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/entity_types/client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/entity_types/pagers.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/base.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/grpc.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/rest.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/environments/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/environments/async_client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/environments/client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/environments/pagers.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/environments/transports/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/environments/transports/base.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/environments/transports/grpc.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/environments/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/environments/transports/rest.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/experiments/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/experiments/async_client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/experiments/client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/experiments/pagers.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/base.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/grpc.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/rest.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/flows/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/flows/async_client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/flows/client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/flows/pagers.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/flows/transports/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/flows/transports/base.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/flows/transports/grpc.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/flows/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/flows/transports/rest.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/intents/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/intents/async_client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/intents/client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/intents/pagers.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/intents/transports/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/intents/transports/base.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/intents/transports/grpc.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/intents/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/intents/transports/rest.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/pages/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/pages/async_client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/pages/client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/pages/pagers.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/pages/transports/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/pages/transports/base.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/pages/transports/grpc.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/pages/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/pages/transports/rest.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/async_client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/pagers.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/transports/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/transports/base.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/transports/grpc.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/transports/rest.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/async_client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/pagers.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/transports/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/transports/base.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/transports/grpc.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/transports/rest.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/sessions/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/sessions/async_client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/sessions/client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/base.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/grpc.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/rest.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/test_cases/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/test_cases/async_client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/test_cases/client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/test_cases/pagers.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/base.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/grpc.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/rest.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/async_client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/pagers.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/transports/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/transports/base.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/transports/grpc.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/transports/rest.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/versions/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/versions/async_client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/versions/client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/versions/pagers.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/versions/transports/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/versions/transports/base.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/versions/transports/rest.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/webhooks/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/webhooks/async_client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/webhooks/client.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/webhooks/pagers.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/base.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/grpc.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/rest.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/__init__.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/advanced_settings.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/agent.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/audio_config.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/changelog.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/deployment.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/entity_type.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/environment.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/experiment.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/flow.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/fulfillment.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/gcs.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/import_strategy.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/intent.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/page.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/response_message.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/security_settings.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/session.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/session_entity_type.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/test_case.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/transition_route_group.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/validation_message.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/version.py delete mode 100644 owl-bot-staging/v3beta1/google/cloud/dialogflowcx_v3beta1/types/webhook.py delete mode 100644 owl-bot-staging/v3beta1/mypy.ini delete mode 100644 owl-bot-staging/v3beta1/noxfile.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_agents_create_agent_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_agents_create_agent_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_agents_delete_agent_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_agents_delete_agent_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_agents_export_agent_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_agents_export_agent_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_agents_get_agent_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_agents_get_agent_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_agents_get_agent_validation_result_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_agents_get_agent_validation_result_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_agents_list_agents_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_agents_list_agents_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_agents_restore_agent_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_agents_restore_agent_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_agents_update_agent_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_agents_update_agent_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_agents_validate_agent_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_agents_validate_agent_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_changelogs_get_changelog_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_changelogs_get_changelog_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_changelogs_list_changelogs_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_changelogs_list_changelogs_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_deployments_get_deployment_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_deployments_get_deployment_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_deployments_list_deployments_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_deployments_list_deployments_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_create_entity_type_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_create_entity_type_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_delete_entity_type_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_delete_entity_type_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_get_entity_type_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_get_entity_type_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_list_entity_types_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_list_entity_types_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_update_entity_type_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_update_entity_type_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_environments_create_environment_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_environments_create_environment_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_environments_delete_environment_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_environments_delete_environment_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_environments_deploy_flow_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_environments_deploy_flow_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_environments_get_environment_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_environments_get_environment_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_environments_list_continuous_test_results_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_environments_list_continuous_test_results_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_environments_list_environments_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_environments_list_environments_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_environments_lookup_environment_history_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_environments_lookup_environment_history_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_environments_run_continuous_test_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_environments_run_continuous_test_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_environments_update_environment_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_environments_update_environment_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_experiments_create_experiment_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_experiments_create_experiment_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_experiments_delete_experiment_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_experiments_delete_experiment_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_experiments_get_experiment_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_experiments_get_experiment_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_experiments_list_experiments_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_experiments_list_experiments_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_experiments_start_experiment_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_experiments_start_experiment_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_experiments_stop_experiment_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_experiments_stop_experiment_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_experiments_update_experiment_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_experiments_update_experiment_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_flows_create_flow_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_flows_create_flow_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_flows_delete_flow_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_flows_delete_flow_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_flows_export_flow_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_flows_export_flow_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_flows_get_flow_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_flows_get_flow_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_flows_get_flow_validation_result_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_flows_get_flow_validation_result_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_flows_import_flow_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_flows_import_flow_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_flows_list_flows_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_flows_list_flows_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_flows_train_flow_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_flows_train_flow_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_flows_update_flow_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_flows_update_flow_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_flows_validate_flow_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_flows_validate_flow_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_intents_create_intent_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_intents_create_intent_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_intents_delete_intent_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_intents_delete_intent_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_intents_get_intent_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_intents_get_intent_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_intents_list_intents_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_intents_list_intents_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_intents_update_intent_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_intents_update_intent_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_pages_create_page_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_pages_create_page_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_pages_delete_page_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_pages_delete_page_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_pages_get_page_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_pages_get_page_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_pages_list_pages_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_pages_list_pages_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_pages_update_page_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_pages_update_page_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_create_security_settings_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_create_security_settings_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_delete_security_settings_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_delete_security_settings_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_get_security_settings_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_get_security_settings_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_list_security_settings_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_list_security_settings_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_update_security_settings_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_update_security_settings_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_create_session_entity_type_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_create_session_entity_type_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_delete_session_entity_type_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_delete_session_entity_type_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_get_session_entity_type_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_get_session_entity_type_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_list_session_entity_types_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_list_session_entity_types_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_update_session_entity_type_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_update_session_entity_type_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_sessions_detect_intent_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_sessions_detect_intent_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_sessions_fulfill_intent_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_sessions_fulfill_intent_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_sessions_match_intent_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_sessions_match_intent_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_sessions_streaming_detect_intent_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_sessions_streaming_detect_intent_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_batch_delete_test_cases_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_batch_delete_test_cases_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_batch_run_test_cases_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_batch_run_test_cases_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_calculate_coverage_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_calculate_coverage_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_create_test_case_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_create_test_case_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_export_test_cases_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_export_test_cases_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_get_test_case_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_get_test_case_result_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_get_test_case_result_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_get_test_case_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_import_test_cases_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_import_test_cases_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_list_test_case_results_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_list_test_case_results_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_list_test_cases_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_list_test_cases_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_run_test_case_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_run_test_case_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_update_test_case_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_update_test_case_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_create_transition_route_group_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_create_transition_route_group_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_delete_transition_route_group_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_delete_transition_route_group_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_get_transition_route_group_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_get_transition_route_group_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_list_transition_route_groups_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_list_transition_route_groups_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_update_transition_route_group_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_update_transition_route_group_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_versions_compare_versions_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_versions_compare_versions_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_versions_create_version_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_versions_create_version_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_versions_delete_version_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_versions_delete_version_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_versions_get_version_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_versions_get_version_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_versions_list_versions_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_versions_list_versions_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_versions_load_version_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_versions_load_version_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_versions_update_version_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_versions_update_version_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_create_webhook_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_create_webhook_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_delete_webhook_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_delete_webhook_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_get_webhook_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_get_webhook_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_list_webhooks_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_list_webhooks_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_update_webhook_async.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_update_webhook_sync.py delete mode 100644 owl-bot-staging/v3beta1/samples/generated_samples/snippet_metadata_google.cloud.dialogflow.cx.v3beta1.json delete mode 100644 owl-bot-staging/v3beta1/scripts/fixup_dialogflowcx_v3beta1_keywords.py delete mode 100644 owl-bot-staging/v3beta1/setup.py delete mode 100644 owl-bot-staging/v3beta1/testing/constraints-3.10.txt delete mode 100644 owl-bot-staging/v3beta1/testing/constraints-3.11.txt delete mode 100644 owl-bot-staging/v3beta1/testing/constraints-3.12.txt delete mode 100644 owl-bot-staging/v3beta1/testing/constraints-3.7.txt delete mode 100644 owl-bot-staging/v3beta1/testing/constraints-3.8.txt delete mode 100644 owl-bot-staging/v3beta1/testing/constraints-3.9.txt delete mode 100644 owl-bot-staging/v3beta1/tests/__init__.py delete mode 100644 owl-bot-staging/v3beta1/tests/unit/__init__.py delete mode 100644 owl-bot-staging/v3beta1/tests/unit/gapic/__init__.py delete mode 100644 owl-bot-staging/v3beta1/tests/unit/gapic/dialogflowcx_v3beta1/__init__.py delete mode 100644 owl-bot-staging/v3beta1/tests/unit/gapic/dialogflowcx_v3beta1/test_agents.py delete mode 100644 owl-bot-staging/v3beta1/tests/unit/gapic/dialogflowcx_v3beta1/test_changelogs.py delete mode 100644 owl-bot-staging/v3beta1/tests/unit/gapic/dialogflowcx_v3beta1/test_deployments.py delete mode 100644 owl-bot-staging/v3beta1/tests/unit/gapic/dialogflowcx_v3beta1/test_entity_types.py delete mode 100644 owl-bot-staging/v3beta1/tests/unit/gapic/dialogflowcx_v3beta1/test_environments.py delete mode 100644 owl-bot-staging/v3beta1/tests/unit/gapic/dialogflowcx_v3beta1/test_experiments.py delete mode 100644 owl-bot-staging/v3beta1/tests/unit/gapic/dialogflowcx_v3beta1/test_flows.py delete mode 100644 owl-bot-staging/v3beta1/tests/unit/gapic/dialogflowcx_v3beta1/test_intents.py delete mode 100644 owl-bot-staging/v3beta1/tests/unit/gapic/dialogflowcx_v3beta1/test_pages.py delete mode 100644 owl-bot-staging/v3beta1/tests/unit/gapic/dialogflowcx_v3beta1/test_security_settings_service.py delete mode 100644 owl-bot-staging/v3beta1/tests/unit/gapic/dialogflowcx_v3beta1/test_session_entity_types.py delete mode 100644 owl-bot-staging/v3beta1/tests/unit/gapic/dialogflowcx_v3beta1/test_sessions.py delete mode 100644 owl-bot-staging/v3beta1/tests/unit/gapic/dialogflowcx_v3beta1/test_test_cases.py delete mode 100644 owl-bot-staging/v3beta1/tests/unit/gapic/dialogflowcx_v3beta1/test_transition_route_groups.py delete mode 100644 owl-bot-staging/v3beta1/tests/unit/gapic/dialogflowcx_v3beta1/test_versions.py delete mode 100644 owl-bot-staging/v3beta1/tests/unit/gapic/dialogflowcx_v3beta1/test_webhooks.py diff --git a/google/cloud/dialogflowcx/__init__.py b/google/cloud/dialogflowcx/__init__.py index a829256b..c622d0ba 100644 --- a/google/cloud/dialogflowcx/__init__.py +++ b/google/cloud/dialogflowcx/__init__.py @@ -167,6 +167,7 @@ from google.cloud.dialogflowcx_v3.types.flow import ExportFlowRequest from google.cloud.dialogflowcx_v3.types.flow import ExportFlowResponse from google.cloud.dialogflowcx_v3.types.flow import Flow +from google.cloud.dialogflowcx_v3.types.flow import FlowImportStrategy from google.cloud.dialogflowcx_v3.types.flow import FlowValidationResult from google.cloud.dialogflowcx_v3.types.flow import GetFlowRequest from google.cloud.dialogflowcx_v3.types.flow import GetFlowValidationResultRequest @@ -180,6 +181,7 @@ from google.cloud.dialogflowcx_v3.types.flow import ValidateFlowRequest from google.cloud.dialogflowcx_v3.types.fulfillment import Fulfillment from google.cloud.dialogflowcx_v3.types.gcs import GcsDestination +from google.cloud.dialogflowcx_v3.types.import_strategy import ImportStrategy from google.cloud.dialogflowcx_v3.types.intent import CreateIntentRequest from google.cloud.dialogflowcx_v3.types.intent import DeleteIntentRequest from google.cloud.dialogflowcx_v3.types.intent import GetIntentRequest @@ -446,6 +448,7 @@ "ExportFlowRequest", "ExportFlowResponse", "Flow", + "FlowImportStrategy", "FlowValidationResult", "GetFlowRequest", "GetFlowValidationResultRequest", @@ -459,6 +462,7 @@ "ValidateFlowRequest", "Fulfillment", "GcsDestination", + "ImportStrategy", "CreateIntentRequest", "DeleteIntentRequest", "GetIntentRequest", diff --git a/google/cloud/dialogflowcx_v3/__init__.py b/google/cloud/dialogflowcx_v3/__init__.py index 27e213bd..f2d54b1d 100644 --- a/google/cloud/dialogflowcx_v3/__init__.py +++ b/google/cloud/dialogflowcx_v3/__init__.py @@ -127,6 +127,7 @@ from .types.flow import ExportFlowRequest from .types.flow import ExportFlowResponse from .types.flow import Flow +from .types.flow import FlowImportStrategy from .types.flow import FlowValidationResult from .types.flow import GetFlowRequest from .types.flow import GetFlowValidationResultRequest @@ -140,6 +141,7 @@ from .types.flow import ValidateFlowRequest from .types.fulfillment import Fulfillment from .types.gcs import GcsDestination +from .types.import_strategy import ImportStrategy from .types.intent import CreateIntentRequest from .types.intent import DeleteIntentRequest from .types.intent import GetIntentRequest @@ -345,6 +347,7 @@ "ExportTestCasesRequest", "ExportTestCasesResponse", "Flow", + "FlowImportStrategy", "FlowValidationResult", "FlowsClient", "Form", @@ -372,6 +375,7 @@ "GetWebhookRequest", "ImportFlowRequest", "ImportFlowResponse", + "ImportStrategy", "ImportTestCasesMetadata", "ImportTestCasesRequest", "ImportTestCasesResponse", diff --git a/google/cloud/dialogflowcx_v3/services/agents/async_client.py b/google/cloud/dialogflowcx_v3/services/agents/async_client.py index 0b4b9d0b..ba078806 100644 --- a/google/cloud/dialogflowcx_v3/services/agents/async_client.py +++ b/google/cloud/dialogflowcx_v3/services/agents/async_client.py @@ -417,7 +417,8 @@ async def sample_get_agent(): [Flows][google.cloud.dialogflow.cx.v3.Flow], [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment], [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], - and so on to manage the conversation flows.. + [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] + and so on to manage the conversation flows. """ # Create or coerce a protobuf request object. @@ -547,7 +548,8 @@ async def sample_create_agent(): [Flows][google.cloud.dialogflow.cx.v3.Flow], [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment], [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], - and so on to manage the conversation flows.. + [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] + and so on to manage the conversation flows. """ # Create or coerce a protobuf request object. @@ -688,7 +690,8 @@ async def sample_update_agent(): [Flows][google.cloud.dialogflow.cx.v3.Flow], [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment], [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], - and so on to manage the conversation flows.. + [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] + and so on to manage the conversation flows. """ # Create or coerce a protobuf request object. diff --git a/google/cloud/dialogflowcx_v3/services/agents/client.py b/google/cloud/dialogflowcx_v3/services/agents/client.py index ca05e036..de412c5a 100644 --- a/google/cloud/dialogflowcx_v3/services/agents/client.py +++ b/google/cloud/dialogflowcx_v3/services/agents/client.py @@ -752,7 +752,8 @@ def sample_get_agent(): [Flows][google.cloud.dialogflow.cx.v3.Flow], [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment], [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], - and so on to manage the conversation flows.. + [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] + and so on to manage the conversation flows. """ # Create or coerce a protobuf request object. @@ -882,7 +883,8 @@ def sample_create_agent(): [Flows][google.cloud.dialogflow.cx.v3.Flow], [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment], [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], - and so on to manage the conversation flows.. + [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] + and so on to manage the conversation flows. """ # Create or coerce a protobuf request object. @@ -1014,7 +1016,8 @@ def sample_update_agent(): [Flows][google.cloud.dialogflow.cx.v3.Flow], [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment], [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], - and so on to manage the conversation flows.. + [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] + and so on to manage the conversation flows. """ # Create or coerce a protobuf request object. diff --git a/google/cloud/dialogflowcx_v3/services/agents/transports/rest.py b/google/cloud/dialogflowcx_v3/services/agents/transports/rest.py index 644b4d4e..b6602823 100644 --- a/google/cloud/dialogflowcx_v3/services/agents/transports/rest.py +++ b/google/cloud/dialogflowcx_v3/services/agents/transports/rest.py @@ -640,8 +640,9 @@ def __call__( Types][google.cloud.dialogflow.cx.v3.EntityType], [Flows][google.cloud.dialogflow.cx.v3.Flow], [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment], - [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], and - so on to manage the conversation flows.. + [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], + [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] + and so on to manage the conversation flows. """ @@ -921,8 +922,9 @@ def __call__( Types][google.cloud.dialogflow.cx.v3.EntityType], [Flows][google.cloud.dialogflow.cx.v3.Flow], [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment], - [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], and - so on to manage the conversation flows.. + [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], + [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] + and so on to manage the conversation flows. """ @@ -1299,8 +1301,9 @@ def __call__( Types][google.cloud.dialogflow.cx.v3.EntityType], [Flows][google.cloud.dialogflow.cx.v3.Flow], [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment], - [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], and - so on to manage the conversation flows.. + [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], + [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] + and so on to manage the conversation flows. """ diff --git a/google/cloud/dialogflowcx_v3/services/transition_route_groups/async_client.py b/google/cloud/dialogflowcx_v3/services/transition_route_groups/async_client.py index 7b73703b..c9712d7e 100644 --- a/google/cloud/dialogflowcx_v3/services/transition_route_groups/async_client.py +++ b/google/cloud/dialogflowcx_v3/services/transition_route_groups/async_client.py @@ -285,7 +285,8 @@ async def sample_list_transition_route_groups(): parent (:class:`str`): Required. The flow to list all transition route groups for. Format: - ``projects//locations//agents//flows/``. + ``projects//locations//agents//flows/`` + or \`projects//locations//agents/. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this @@ -404,7 +405,9 @@ async def sample_get_transition_route_group(): Required. The name of the [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. Format: - ``projects//locations//agents//flows//transitionRouteGroups/``. + ``projects//locations//agents//flows//transitionRouteGroups/`` + or + ``projects//locations//agents//transitionRouteGroups/``. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this @@ -417,7 +420,7 @@ async def sample_get_transition_route_group(): Returns: google.cloud.dialogflowcx_v3.types.TransitionRouteGroup: - An TransitionRouteGroup represents a group of + A TransitionRouteGroup represents a group of [TransitionRoutes][google.cloud.dialogflow.cx.v3.TransitionRoute] to be used by a [Page][google.cloud.dialogflow.cx.v3.Page]. @@ -525,7 +528,10 @@ async def sample_create_transition_route_group(): Required. The flow to create an [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] for. Format: - ``projects//locations//agents//flows/``. + ``projects//locations//agents//flows/`` + or + ``projects//locations//agents/`` + for agent-level groups. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this @@ -545,7 +551,7 @@ async def sample_create_transition_route_group(): Returns: google.cloud.dialogflowcx_v3.types.TransitionRouteGroup: - An TransitionRouteGroup represents a group of + A TransitionRouteGroup represents a group of [TransitionRoutes][google.cloud.dialogflow.cx.v3.TransitionRoute] to be used by a [Page][google.cloud.dialogflow.cx.v3.Page]. @@ -671,7 +677,7 @@ async def sample_update_transition_route_group(): Returns: google.cloud.dialogflowcx_v3.types.TransitionRouteGroup: - An TransitionRouteGroup represents a group of + A TransitionRouteGroup represents a group of [TransitionRoutes][google.cloud.dialogflow.cx.v3.TransitionRoute] to be used by a [Page][google.cloud.dialogflow.cx.v3.Page]. @@ -772,7 +778,9 @@ async def sample_delete_transition_route_group(): Required. The name of the [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] to delete. Format: - ``projects//locations//agents//flows//transitionRouteGroups/``. + ``projects//locations//agents//flows//transitionRouteGroups/`` + or + ``projects//locations//agents//transitionRouteGroups/``. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this diff --git a/google/cloud/dialogflowcx_v3/services/transition_route_groups/client.py b/google/cloud/dialogflowcx_v3/services/transition_route_groups/client.py index 57ff357c..c53d35a0 100644 --- a/google/cloud/dialogflowcx_v3/services/transition_route_groups/client.py +++ b/google/cloud/dialogflowcx_v3/services/transition_route_groups/client.py @@ -601,7 +601,8 @@ def sample_list_transition_route_groups(): parent (str): Required. The flow to list all transition route groups for. Format: - ``projects//locations//agents//flows/``. + ``projects//locations//agents//flows/`` + or \`projects//locations//agents/. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this @@ -724,7 +725,9 @@ def sample_get_transition_route_group(): Required. The name of the [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. Format: - ``projects//locations//agents//flows//transitionRouteGroups/``. + ``projects//locations//agents//flows//transitionRouteGroups/`` + or + ``projects//locations//agents//transitionRouteGroups/``. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this @@ -737,7 +740,7 @@ def sample_get_transition_route_group(): Returns: google.cloud.dialogflowcx_v3.types.TransitionRouteGroup: - An TransitionRouteGroup represents a group of + A TransitionRouteGroup represents a group of [TransitionRoutes][google.cloud.dialogflow.cx.v3.TransitionRoute] to be used by a [Page][google.cloud.dialogflow.cx.v3.Page]. @@ -849,7 +852,10 @@ def sample_create_transition_route_group(): Required. The flow to create an [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] for. Format: - ``projects//locations//agents//flows/``. + ``projects//locations//agents//flows/`` + or + ``projects//locations//agents/`` + for agent-level groups. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this @@ -869,7 +875,7 @@ def sample_create_transition_route_group(): Returns: google.cloud.dialogflowcx_v3.types.TransitionRouteGroup: - An TransitionRouteGroup represents a group of + A TransitionRouteGroup represents a group of [TransitionRoutes][google.cloud.dialogflow.cx.v3.TransitionRoute] to be used by a [Page][google.cloud.dialogflow.cx.v3.Page]. @@ -1001,7 +1007,7 @@ def sample_update_transition_route_group(): Returns: google.cloud.dialogflowcx_v3.types.TransitionRouteGroup: - An TransitionRouteGroup represents a group of + A TransitionRouteGroup represents a group of [TransitionRoutes][google.cloud.dialogflow.cx.v3.TransitionRoute] to be used by a [Page][google.cloud.dialogflow.cx.v3.Page]. @@ -1108,7 +1114,9 @@ def sample_delete_transition_route_group(): Required. The name of the [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] to delete. Format: - ``projects//locations//agents//flows//transitionRouteGroups/``. + ``projects//locations//agents//flows//transitionRouteGroups/`` + or + ``projects//locations//agents//transitionRouteGroups/``. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this diff --git a/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/rest.py b/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/rest.py index 6d58d14f..17592dbf 100644 --- a/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/rest.py +++ b/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/rest.py @@ -483,7 +483,7 @@ def __call__( Returns: ~.gcdc_transition_route_group.TransitionRouteGroup: - An TransitionRouteGroup represents a group of + A TransitionRouteGroup represents a group of [``TransitionRoutes``][google.cloud.dialogflow.cx.v3.TransitionRoute] to be used by a [Page][google.cloud.dialogflow.cx.v3.Page]. @@ -496,6 +496,11 @@ def __call__( "uri": "/v3/{parent=projects/*/locations/*/agents/*/flows/*}/transitionRouteGroups", "body": "transition_route_group", }, + { + "method": "post", + "uri": "/v3/{parent=projects/*/locations/*/agents/*}/transitionRouteGroups", + "body": "transition_route_group", + }, ] request, metadata = self._interceptor.pre_create_transition_route_group( request, metadata @@ -594,6 +599,10 @@ def __call__( "method": "delete", "uri": "/v3/{name=projects/*/locations/*/agents/*/flows/*/transitionRouteGroups/*}", }, + { + "method": "delete", + "uri": "/v3/{name=projects/*/locations/*/agents/*/transitionRouteGroups/*}", + }, ] request, metadata = self._interceptor.pre_delete_transition_route_group( request, metadata @@ -670,7 +679,7 @@ def __call__( Returns: ~.transition_route_group.TransitionRouteGroup: - An TransitionRouteGroup represents a group of + A TransitionRouteGroup represents a group of [``TransitionRoutes``][google.cloud.dialogflow.cx.v3.TransitionRoute] to be used by a [Page][google.cloud.dialogflow.cx.v3.Page]. @@ -682,6 +691,10 @@ def __call__( "method": "get", "uri": "/v3/{name=projects/*/locations/*/agents/*/flows/*/transitionRouteGroups/*}", }, + { + "method": "get", + "uri": "/v3/{name=projects/*/locations/*/agents/*/transitionRouteGroups/*}", + }, ] request, metadata = self._interceptor.pre_get_transition_route_group( request, metadata @@ -776,6 +789,10 @@ def __call__( "method": "get", "uri": "/v3/{parent=projects/*/locations/*/agents/*/flows/*}/transitionRouteGroups", }, + { + "method": "get", + "uri": "/v3/{parent=projects/*/locations/*/agents/*}/transitionRouteGroups", + }, ] request, metadata = self._interceptor.pre_list_transition_route_groups( request, metadata @@ -860,7 +877,7 @@ def __call__( Returns: ~.gcdc_transition_route_group.TransitionRouteGroup: - An TransitionRouteGroup represents a group of + A TransitionRouteGroup represents a group of [``TransitionRoutes``][google.cloud.dialogflow.cx.v3.TransitionRoute] to be used by a [Page][google.cloud.dialogflow.cx.v3.Page]. @@ -873,6 +890,11 @@ def __call__( "uri": "/v3/{transition_route_group.name=projects/*/locations/*/agents/*/flows/*/transitionRouteGroups/*}", "body": "transition_route_group", }, + { + "method": "patch", + "uri": "/v3/{transition_route_group.name=projects/*/locations/*/agents/*/transitionRouteGroups/*}", + "body": "transition_route_group", + }, ] request, metadata = self._interceptor.pre_update_transition_route_group( request, metadata diff --git a/google/cloud/dialogflowcx_v3/types/__init__.py b/google/cloud/dialogflowcx_v3/types/__init__.py index 108b7534..4a6bbcd2 100644 --- a/google/cloud/dialogflowcx_v3/types/__init__.py +++ b/google/cloud/dialogflowcx_v3/types/__init__.py @@ -106,6 +106,7 @@ ExportFlowRequest, ExportFlowResponse, Flow, + FlowImportStrategy, FlowValidationResult, GetFlowRequest, GetFlowValidationResultRequest, @@ -342,6 +343,7 @@ "ExportFlowRequest", "ExportFlowResponse", "Flow", + "FlowImportStrategy", "FlowValidationResult", "GetFlowRequest", "GetFlowValidationResultRequest", @@ -355,6 +357,7 @@ "ValidateFlowRequest", "Fulfillment", "GcsDestination", + "ImportStrategy", "CreateIntentRequest", "DeleteIntentRequest", "GetIntentRequest", diff --git a/google/cloud/dialogflowcx_v3/types/agent.py b/google/cloud/dialogflowcx_v3/types/agent.py index 82801e86..bbee8d20 100644 --- a/google/cloud/dialogflowcx_v3/types/agent.py +++ b/google/cloud/dialogflowcx_v3/types/agent.py @@ -74,8 +74,9 @@ class Agent(proto.Message): Types][google.cloud.dialogflow.cx.v3.EntityType], [Flows][google.cloud.dialogflow.cx.v3.Flow], [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment], - [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], and so on to - manage the conversation flows.. + [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], + [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] + and so on to manage the conversation flows. Attributes: name (str): @@ -173,8 +174,8 @@ class GithubSettings(proto.Message): The GitHub repository URI related to the agent. tracking_branch (str): - The branch of GitHub repository tracked for - this agent. + The branch of the GitHub repository tracked + for this agent. access_token (str): The access token used to authenticate the access to the GitHub repository. @@ -545,7 +546,7 @@ class ExportAgentResponse(proto.Message): This field is a member of `oneof`_ ``agent``. commit_sha (str): Commit SHA of the git push. This field is populated if - ``git_destination`` are specified in + ``git_destination`` is specified in [ExportAgentRequest][google.cloud.dialogflow.cx.v3.ExportAgentRequest]. This field is a member of `oneof`_ ``agent``. diff --git a/google/cloud/dialogflowcx_v3/types/flow.py b/google/cloud/dialogflowcx_v3/types/flow.py index 1c46ed9c..372913ad 100644 --- a/google/cloud/dialogflowcx_v3/types/flow.py +++ b/google/cloud/dialogflowcx_v3/types/flow.py @@ -19,6 +19,7 @@ import proto # type: ignore +from google.cloud.dialogflowcx_v3.types import import_strategy from google.cloud.dialogflowcx_v3.types import page from google.cloud.dialogflowcx_v3.types import validation_message from google.protobuf import field_mask_pb2 # type: ignore @@ -41,6 +42,7 @@ "GetFlowValidationResultRequest", "FlowValidationResult", "ImportFlowRequest", + "FlowImportStrategy", "ImportFlowResponse", "ExportFlowRequest", "ExportFlowResponse", @@ -193,7 +195,10 @@ class Flow(proto.Message): groups defined in the page have higher priority than those defined in the flow. - Format:\ ``projects//locations//agents//flows//transitionRouteGroups/``. + Format:\ ``projects//locations//agents//flows//transitionRouteGroups/`` + or + ``projects//locations//agents//transitionRouteGroups/`` + for agent-level groups. nlu_settings (google.cloud.dialogflowcx_v3.types.NluSettings): NLU related settings of the flow. """ @@ -584,6 +589,9 @@ class ImportFlowRequest(proto.Message): This field is a member of `oneof`_ ``flow``. import_option (google.cloud.dialogflowcx_v3.types.ImportFlowRequest.ImportOption): Flow import mode. If not specified, ``KEEP`` is assumed. + flow_import_strategy (google.cloud.dialogflowcx_v3.types.FlowImportStrategy): + Optional. Specifies the import strategy used + when resolving resource conflicts. """ class ImportOption(proto.Enum): @@ -626,6 +634,31 @@ class ImportOption(proto.Enum): number=4, enum=ImportOption, ) + flow_import_strategy: "FlowImportStrategy" = proto.Field( + proto.MESSAGE, + number=5, + message="FlowImportStrategy", + ) + + +class FlowImportStrategy(proto.Message): + r"""The flow import strategy used for resource conflict resolution + associated with an + [ImportFlowRequest][google.cloud.dialogflow.cx.v3.ImportFlowRequest]. + + Attributes: + global_import_strategy (google.cloud.dialogflowcx_v3.types.ImportStrategy): + Optional. Import strategy for resource conflict resolution, + applied globally throughout the flow. It will be applied for + all display name conflicts in the imported content. If not + specified, 'CREATE_NEW' is assumed. + """ + + global_import_strategy: import_strategy.ImportStrategy = proto.Field( + proto.ENUM, + number=1, + enum=import_strategy.ImportStrategy, + ) class ImportFlowResponse(proto.Message): diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/import_strategy.py b/google/cloud/dialogflowcx_v3/types/import_strategy.py similarity index 96% rename from owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/import_strategy.py rename to google/cloud/dialogflowcx_v3/types/import_strategy.py index aa15036d..6732226a 100644 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/import_strategy.py +++ b/google/cloud/dialogflowcx_v3/types/import_strategy.py @@ -21,9 +21,9 @@ __protobuf__ = proto.module( - package='google.cloud.dialogflow.cx.v3', + package="google.cloud.dialogflow.cx.v3", manifest={ - 'ImportStrategy', + "ImportStrategy", }, ) diff --git a/google/cloud/dialogflowcx_v3/types/page.py b/google/cloud/dialogflowcx_v3/types/page.py index 20bfab7b..522967a3 100644 --- a/google/cloud/dialogflowcx_v3/types/page.py +++ b/google/cloud/dialogflowcx_v3/types/page.py @@ -94,7 +94,10 @@ class Page(proto.Message): the same intent, then the first group in the ordered list takes precedence. - Format:\ ``projects//locations//agents//flows//transitionRouteGroups/``. + Format:\ ``projects//locations//agents//flows//transitionRouteGroups/`` + or + ``projects//locations//agents//transitionRouteGroups/`` + for agent-level groups. transition_routes (MutableSequence[google.cloud.dialogflowcx_v3.types.TransitionRoute]): A list of transitions for the transition rules of this page. They route the conversation to another page in the same diff --git a/google/cloud/dialogflowcx_v3/types/response_message.py b/google/cloud/dialogflowcx_v3/types/response_message.py index 4dc1de1b..9505fb7a 100644 --- a/google/cloud/dialogflowcx_v3/types/response_message.py +++ b/google/cloud/dialogflowcx_v3/types/response_message.py @@ -118,6 +118,8 @@ class ResponseMessage(proto.Message): third-party endpoint. This field is a member of `oneof`_ ``message``. + response_type (google.cloud.dialogflowcx_v3.types.ResponseMessage.ResponseType): + Response type. channel (str): The channel which the response is associated with. Clients can specify the channel via @@ -125,6 +127,31 @@ class ResponseMessage(proto.Message): and only associated channel response will be returned. """ + class ResponseType(proto.Enum): + r"""Represents different response types. + + Values: + RESPONSE_TYPE_UNSPECIFIED (0): + Not specified. + ENTRY_PROMPT (1): + The response is from an [entry + prompt][google.cloud.dialogflow.cx.v3.Page.entry_fulfillment] + in the page. + PARAMETER_PROMPT (2): + The response is from [form-filling + prompt][google.cloud.dialogflow.cx.v3.Form.Parameter.fill_behavior] + in the page. + HANDLER_PROMPT (3): + The response is from a [transition + route][google.cloud.dialogflow.cx.v3.TransitionRoute] or an + [event handler][EventHandler] in the page or flow or + transition route group. + """ + RESPONSE_TYPE_UNSPECIFIED = 0 + ENTRY_PROMPT = 1 + PARAMETER_PROMPT = 2 + HANDLER_PROMPT = 3 + class Text(proto.Message): r"""The text response message. @@ -427,6 +454,11 @@ class TelephonyTransferCall(proto.Message): oneof="message", message=TelephonyTransferCall, ) + response_type: ResponseType = proto.Field( + proto.ENUM, + number=4, + enum=ResponseType, + ) channel: str = proto.Field( proto.STRING, number=19, diff --git a/google/cloud/dialogflowcx_v3/types/session.py b/google/cloud/dialogflowcx_v3/types/session.py index b9bc3dfc..78d89c0d 100644 --- a/google/cloud/dialogflowcx_v3/types/session.py +++ b/google/cloud/dialogflowcx_v3/types/session.py @@ -848,14 +848,14 @@ class QueryParameters(proto.Message): class QueryInput(proto.Message): r"""Represents the query input. It can contain one of: - 1. A conversational query in the form of text. + 1. A conversational query in the form of text. - 2. An intent query that specifies which intent to trigger. - 3. Natural language speech audio to be processed. + 2. An intent query that specifies which intent to trigger. + 3. Natural language speech audio to be processed. - 4. An event to be triggered. + 4. An event to be triggered. - 5. DTMF digits to invoke an intent and fill in parameter value. + 5. DTMF digits to invoke an intent and fill in parameter value. This message has `oneof`_ fields (mutually exclusive fields). For each oneof, at most one member field can be set at the same time. diff --git a/google/cloud/dialogflowcx_v3/types/transition_route_group.py b/google/cloud/dialogflowcx_v3/types/transition_route_group.py index 951aa699..d612a5e9 100644 --- a/google/cloud/dialogflowcx_v3/types/transition_route_group.py +++ b/google/cloud/dialogflowcx_v3/types/transition_route_group.py @@ -38,7 +38,7 @@ class TransitionRouteGroup(proto.Message): - r"""An TransitionRouteGroup represents a group of + r"""A TransitionRouteGroup represents a group of [``TransitionRoutes``][google.cloud.dialogflow.cx.v3.TransitionRoute] to be used by a [Page][google.cloud.dialogflow.cx.v3.Page]. @@ -47,7 +47,8 @@ class TransitionRouteGroup(proto.Message): The unique identifier of the transition route group. [TransitionRouteGroups.CreateTransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroups.CreateTransitionRouteGroup] populates the name automatically. Format: - ``projects//locations//agents//flows//transitionRouteGroups/``. + ``projects//locations//agents//flows//transitionRouteGroups/`` + . display_name (str): Required. The human-readable name of the transition route group, unique within the flow. @@ -81,7 +82,8 @@ class ListTransitionRouteGroupsRequest(proto.Message): parent (str): Required. The flow to list all transition route groups for. Format: - ``projects//locations//agents//flows/``. + ``projects//locations//agents//flows/`` + or \`projects//locations//agents/. page_size (int): The maximum number of items to return in a single page. By default 100 and at most 1000. @@ -165,7 +167,9 @@ class GetTransitionRouteGroupRequest(proto.Message): Required. The name of the [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. Format: - ``projects//locations//agents//flows//transitionRouteGroups/``. + ``projects//locations//agents//flows//transitionRouteGroups/`` + or + ``projects//locations//agents//transitionRouteGroups/``. language_code (str): The language to retrieve the transition route group for. The following fields are language dependent: @@ -201,7 +205,10 @@ class CreateTransitionRouteGroupRequest(proto.Message): Required. The flow to create an [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] for. Format: - ``projects//locations//agents//flows/``. + ``projects//locations//agents//flows/`` + or + ``projects//locations//agents/`` + for agent-level groups. transition_route_group (google.cloud.dialogflowcx_v3.types.TransitionRouteGroup): Required. The transition route group to create. @@ -287,7 +294,9 @@ class DeleteTransitionRouteGroupRequest(proto.Message): Required. The name of the [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] to delete. Format: - ``projects//locations//agents//flows//transitionRouteGroups/``. + ``projects//locations//agents//flows//transitionRouteGroups/`` + or + ``projects//locations//agents//transitionRouteGroups/``. force (bool): This field has no effect for transition route group that no page is using. If the transition route group is referenced diff --git a/owl-bot-staging/v3/.coveragerc b/owl-bot-staging/v3/.coveragerc deleted file mode 100644 index 8dcabc09..00000000 --- a/owl-bot-staging/v3/.coveragerc +++ /dev/null @@ -1,13 +0,0 @@ -[run] -branch = True - -[report] -show_missing = True -omit = - google/cloud/dialogflowcx/__init__.py - google/cloud/dialogflowcx/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/v3/.flake8 b/owl-bot-staging/v3/.flake8 deleted file mode 100644 index 29227d4c..00000000 --- a/owl-bot-staging/v3/.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/v3/MANIFEST.in b/owl-bot-staging/v3/MANIFEST.in deleted file mode 100644 index 83900298..00000000 --- a/owl-bot-staging/v3/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include google/cloud/dialogflowcx *.py -recursive-include google/cloud/dialogflowcx_v3 *.py diff --git a/owl-bot-staging/v3/README.rst b/owl-bot-staging/v3/README.rst deleted file mode 100644 index bfe57a44..00000000 --- a/owl-bot-staging/v3/README.rst +++ /dev/null @@ -1,49 +0,0 @@ -Python Client for Google Cloud Dialogflowcx 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 Dialogflowcx 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/v3/docs/conf.py b/owl-bot-staging/v3/docs/conf.py deleted file mode 100644 index e50e6da4..00000000 --- a/owl-bot-staging/v3/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-dialogflow-cx 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-dialogflow-cx" -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 = None - -# 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-dialogflow-cx-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-dialogflow-cx.tex", - u"google-cloud-dialogflow-cx 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-dialogflow-cx", - u"Google Cloud Dialogflowcx 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-dialogflow-cx", - u"google-cloud-dialogflow-cx Documentation", - author, - "google-cloud-dialogflow-cx", - "GAPIC library for Google Cloud Dialogflowcx 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/v3/docs/dialogflowcx_v3/agents.rst b/owl-bot-staging/v3/docs/dialogflowcx_v3/agents.rst deleted file mode 100644 index 4deb1730..00000000 --- a/owl-bot-staging/v3/docs/dialogflowcx_v3/agents.rst +++ /dev/null @@ -1,10 +0,0 @@ -Agents ------------------------- - -.. automodule:: google.cloud.dialogflowcx_v3.services.agents - :members: - :inherited-members: - -.. automodule:: google.cloud.dialogflowcx_v3.services.agents.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v3/docs/dialogflowcx_v3/changelogs.rst b/owl-bot-staging/v3/docs/dialogflowcx_v3/changelogs.rst deleted file mode 100644 index 1f064c53..00000000 --- a/owl-bot-staging/v3/docs/dialogflowcx_v3/changelogs.rst +++ /dev/null @@ -1,10 +0,0 @@ -Changelogs ----------------------------- - -.. automodule:: google.cloud.dialogflowcx_v3.services.changelogs - :members: - :inherited-members: - -.. automodule:: google.cloud.dialogflowcx_v3.services.changelogs.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v3/docs/dialogflowcx_v3/deployments.rst b/owl-bot-staging/v3/docs/dialogflowcx_v3/deployments.rst deleted file mode 100644 index 1f065b30..00000000 --- a/owl-bot-staging/v3/docs/dialogflowcx_v3/deployments.rst +++ /dev/null @@ -1,10 +0,0 @@ -Deployments ------------------------------ - -.. automodule:: google.cloud.dialogflowcx_v3.services.deployments - :members: - :inherited-members: - -.. automodule:: google.cloud.dialogflowcx_v3.services.deployments.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v3/docs/dialogflowcx_v3/entity_types.rst b/owl-bot-staging/v3/docs/dialogflowcx_v3/entity_types.rst deleted file mode 100644 index 08e4b6e8..00000000 --- a/owl-bot-staging/v3/docs/dialogflowcx_v3/entity_types.rst +++ /dev/null @@ -1,10 +0,0 @@ -EntityTypes ------------------------------ - -.. automodule:: google.cloud.dialogflowcx_v3.services.entity_types - :members: - :inherited-members: - -.. automodule:: google.cloud.dialogflowcx_v3.services.entity_types.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v3/docs/dialogflowcx_v3/environments.rst b/owl-bot-staging/v3/docs/dialogflowcx_v3/environments.rst deleted file mode 100644 index 246ee15a..00000000 --- a/owl-bot-staging/v3/docs/dialogflowcx_v3/environments.rst +++ /dev/null @@ -1,10 +0,0 @@ -Environments ------------------------------- - -.. automodule:: google.cloud.dialogflowcx_v3.services.environments - :members: - :inherited-members: - -.. automodule:: google.cloud.dialogflowcx_v3.services.environments.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v3/docs/dialogflowcx_v3/experiments.rst b/owl-bot-staging/v3/docs/dialogflowcx_v3/experiments.rst deleted file mode 100644 index 5cba0e2a..00000000 --- a/owl-bot-staging/v3/docs/dialogflowcx_v3/experiments.rst +++ /dev/null @@ -1,10 +0,0 @@ -Experiments ------------------------------ - -.. automodule:: google.cloud.dialogflowcx_v3.services.experiments - :members: - :inherited-members: - -.. automodule:: google.cloud.dialogflowcx_v3.services.experiments.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v3/docs/dialogflowcx_v3/flows.rst b/owl-bot-staging/v3/docs/dialogflowcx_v3/flows.rst deleted file mode 100644 index 77f6398e..00000000 --- a/owl-bot-staging/v3/docs/dialogflowcx_v3/flows.rst +++ /dev/null @@ -1,10 +0,0 @@ -Flows ------------------------ - -.. automodule:: google.cloud.dialogflowcx_v3.services.flows - :members: - :inherited-members: - -.. automodule:: google.cloud.dialogflowcx_v3.services.flows.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v3/docs/dialogflowcx_v3/intents.rst b/owl-bot-staging/v3/docs/dialogflowcx_v3/intents.rst deleted file mode 100644 index 8b9e6dda..00000000 --- a/owl-bot-staging/v3/docs/dialogflowcx_v3/intents.rst +++ /dev/null @@ -1,10 +0,0 @@ -Intents -------------------------- - -.. automodule:: google.cloud.dialogflowcx_v3.services.intents - :members: - :inherited-members: - -.. automodule:: google.cloud.dialogflowcx_v3.services.intents.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v3/docs/dialogflowcx_v3/pages.rst b/owl-bot-staging/v3/docs/dialogflowcx_v3/pages.rst deleted file mode 100644 index 0bbfbced..00000000 --- a/owl-bot-staging/v3/docs/dialogflowcx_v3/pages.rst +++ /dev/null @@ -1,10 +0,0 @@ -Pages ------------------------ - -.. automodule:: google.cloud.dialogflowcx_v3.services.pages - :members: - :inherited-members: - -.. automodule:: google.cloud.dialogflowcx_v3.services.pages.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v3/docs/dialogflowcx_v3/security_settings_service.rst b/owl-bot-staging/v3/docs/dialogflowcx_v3/security_settings_service.rst deleted file mode 100644 index 4b4fa007..00000000 --- a/owl-bot-staging/v3/docs/dialogflowcx_v3/security_settings_service.rst +++ /dev/null @@ -1,10 +0,0 @@ -SecuritySettingsService ------------------------------------------ - -.. automodule:: google.cloud.dialogflowcx_v3.services.security_settings_service - :members: - :inherited-members: - -.. automodule:: google.cloud.dialogflowcx_v3.services.security_settings_service.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v3/docs/dialogflowcx_v3/services.rst b/owl-bot-staging/v3/docs/dialogflowcx_v3/services.rst deleted file mode 100644 index 6a19e426..00000000 --- a/owl-bot-staging/v3/docs/dialogflowcx_v3/services.rst +++ /dev/null @@ -1,21 +0,0 @@ -Services for Google Cloud Dialogflowcx v3 API -============================================= -.. toctree:: - :maxdepth: 2 - - agents - changelogs - deployments - entity_types - environments - experiments - flows - intents - pages - security_settings_service - session_entity_types - sessions - test_cases - transition_route_groups - versions - webhooks diff --git a/owl-bot-staging/v3/docs/dialogflowcx_v3/session_entity_types.rst b/owl-bot-staging/v3/docs/dialogflowcx_v3/session_entity_types.rst deleted file mode 100644 index 46ff0f6e..00000000 --- a/owl-bot-staging/v3/docs/dialogflowcx_v3/session_entity_types.rst +++ /dev/null @@ -1,10 +0,0 @@ -SessionEntityTypes ------------------------------------- - -.. automodule:: google.cloud.dialogflowcx_v3.services.session_entity_types - :members: - :inherited-members: - -.. automodule:: google.cloud.dialogflowcx_v3.services.session_entity_types.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v3/docs/dialogflowcx_v3/sessions.rst b/owl-bot-staging/v3/docs/dialogflowcx_v3/sessions.rst deleted file mode 100644 index 494bceb1..00000000 --- a/owl-bot-staging/v3/docs/dialogflowcx_v3/sessions.rst +++ /dev/null @@ -1,6 +0,0 @@ -Sessions --------------------------- - -.. automodule:: google.cloud.dialogflowcx_v3.services.sessions - :members: - :inherited-members: diff --git a/owl-bot-staging/v3/docs/dialogflowcx_v3/test_cases.rst b/owl-bot-staging/v3/docs/dialogflowcx_v3/test_cases.rst deleted file mode 100644 index 3cad4dd4..00000000 --- a/owl-bot-staging/v3/docs/dialogflowcx_v3/test_cases.rst +++ /dev/null @@ -1,10 +0,0 @@ -TestCases ---------------------------- - -.. automodule:: google.cloud.dialogflowcx_v3.services.test_cases - :members: - :inherited-members: - -.. automodule:: google.cloud.dialogflowcx_v3.services.test_cases.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v3/docs/dialogflowcx_v3/transition_route_groups.rst b/owl-bot-staging/v3/docs/dialogflowcx_v3/transition_route_groups.rst deleted file mode 100644 index d5549da9..00000000 --- a/owl-bot-staging/v3/docs/dialogflowcx_v3/transition_route_groups.rst +++ /dev/null @@ -1,10 +0,0 @@ -TransitionRouteGroups ---------------------------------------- - -.. automodule:: google.cloud.dialogflowcx_v3.services.transition_route_groups - :members: - :inherited-members: - -.. automodule:: google.cloud.dialogflowcx_v3.services.transition_route_groups.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v3/docs/dialogflowcx_v3/types.rst b/owl-bot-staging/v3/docs/dialogflowcx_v3/types.rst deleted file mode 100644 index eee8146a..00000000 --- a/owl-bot-staging/v3/docs/dialogflowcx_v3/types.rst +++ /dev/null @@ -1,6 +0,0 @@ -Types for Google Cloud Dialogflowcx v3 API -========================================== - -.. automodule:: google.cloud.dialogflowcx_v3.types - :members: - :show-inheritance: diff --git a/owl-bot-staging/v3/docs/dialogflowcx_v3/versions.rst b/owl-bot-staging/v3/docs/dialogflowcx_v3/versions.rst deleted file mode 100644 index 2d72f02d..00000000 --- a/owl-bot-staging/v3/docs/dialogflowcx_v3/versions.rst +++ /dev/null @@ -1,10 +0,0 @@ -Versions --------------------------- - -.. automodule:: google.cloud.dialogflowcx_v3.services.versions - :members: - :inherited-members: - -.. automodule:: google.cloud.dialogflowcx_v3.services.versions.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v3/docs/dialogflowcx_v3/webhooks.rst b/owl-bot-staging/v3/docs/dialogflowcx_v3/webhooks.rst deleted file mode 100644 index 2e2f9b8c..00000000 --- a/owl-bot-staging/v3/docs/dialogflowcx_v3/webhooks.rst +++ /dev/null @@ -1,10 +0,0 @@ -Webhooks --------------------------- - -.. automodule:: google.cloud.dialogflowcx_v3.services.webhooks - :members: - :inherited-members: - -.. automodule:: google.cloud.dialogflowcx_v3.services.webhooks.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/v3/docs/index.rst b/owl-bot-staging/v3/docs/index.rst deleted file mode 100644 index eaab73b8..00000000 --- a/owl-bot-staging/v3/docs/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -API Reference -------------- -.. toctree:: - :maxdepth: 2 - - dialogflowcx_v3/services - dialogflowcx_v3/types diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx/__init__.py deleted file mode 100644 index 48d1db26..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx/__init__.py +++ /dev/null @@ -1,505 +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.dialogflowcx import gapic_version as package_version - -__version__ = package_version.__version__ - - -from google.cloud.dialogflowcx_v3.services.agents.client import AgentsClient -from google.cloud.dialogflowcx_v3.services.agents.async_client import AgentsAsyncClient -from google.cloud.dialogflowcx_v3.services.changelogs.client import ChangelogsClient -from google.cloud.dialogflowcx_v3.services.changelogs.async_client import ChangelogsAsyncClient -from google.cloud.dialogflowcx_v3.services.deployments.client import DeploymentsClient -from google.cloud.dialogflowcx_v3.services.deployments.async_client import DeploymentsAsyncClient -from google.cloud.dialogflowcx_v3.services.entity_types.client import EntityTypesClient -from google.cloud.dialogflowcx_v3.services.entity_types.async_client import EntityTypesAsyncClient -from google.cloud.dialogflowcx_v3.services.environments.client import EnvironmentsClient -from google.cloud.dialogflowcx_v3.services.environments.async_client import EnvironmentsAsyncClient -from google.cloud.dialogflowcx_v3.services.experiments.client import ExperimentsClient -from google.cloud.dialogflowcx_v3.services.experiments.async_client import ExperimentsAsyncClient -from google.cloud.dialogflowcx_v3.services.flows.client import FlowsClient -from google.cloud.dialogflowcx_v3.services.flows.async_client import FlowsAsyncClient -from google.cloud.dialogflowcx_v3.services.intents.client import IntentsClient -from google.cloud.dialogflowcx_v3.services.intents.async_client import IntentsAsyncClient -from google.cloud.dialogflowcx_v3.services.pages.client import PagesClient -from google.cloud.dialogflowcx_v3.services.pages.async_client import PagesAsyncClient -from google.cloud.dialogflowcx_v3.services.security_settings_service.client import SecuritySettingsServiceClient -from google.cloud.dialogflowcx_v3.services.security_settings_service.async_client import SecuritySettingsServiceAsyncClient -from google.cloud.dialogflowcx_v3.services.session_entity_types.client import SessionEntityTypesClient -from google.cloud.dialogflowcx_v3.services.session_entity_types.async_client import SessionEntityTypesAsyncClient -from google.cloud.dialogflowcx_v3.services.sessions.client import SessionsClient -from google.cloud.dialogflowcx_v3.services.sessions.async_client import SessionsAsyncClient -from google.cloud.dialogflowcx_v3.services.test_cases.client import TestCasesClient -from google.cloud.dialogflowcx_v3.services.test_cases.async_client import TestCasesAsyncClient -from google.cloud.dialogflowcx_v3.services.transition_route_groups.client import TransitionRouteGroupsClient -from google.cloud.dialogflowcx_v3.services.transition_route_groups.async_client import TransitionRouteGroupsAsyncClient -from google.cloud.dialogflowcx_v3.services.versions.client import VersionsClient -from google.cloud.dialogflowcx_v3.services.versions.async_client import VersionsAsyncClient -from google.cloud.dialogflowcx_v3.services.webhooks.client import WebhooksClient -from google.cloud.dialogflowcx_v3.services.webhooks.async_client import WebhooksAsyncClient - -from google.cloud.dialogflowcx_v3.types.advanced_settings import AdvancedSettings -from google.cloud.dialogflowcx_v3.types.agent import Agent -from google.cloud.dialogflowcx_v3.types.agent import AgentValidationResult -from google.cloud.dialogflowcx_v3.types.agent import CreateAgentRequest -from google.cloud.dialogflowcx_v3.types.agent import DeleteAgentRequest -from google.cloud.dialogflowcx_v3.types.agent import ExportAgentRequest -from google.cloud.dialogflowcx_v3.types.agent import ExportAgentResponse -from google.cloud.dialogflowcx_v3.types.agent import GetAgentRequest -from google.cloud.dialogflowcx_v3.types.agent import GetAgentValidationResultRequest -from google.cloud.dialogflowcx_v3.types.agent import ListAgentsRequest -from google.cloud.dialogflowcx_v3.types.agent import ListAgentsResponse -from google.cloud.dialogflowcx_v3.types.agent import RestoreAgentRequest -from google.cloud.dialogflowcx_v3.types.agent import SpeechToTextSettings -from google.cloud.dialogflowcx_v3.types.agent import UpdateAgentRequest -from google.cloud.dialogflowcx_v3.types.agent import ValidateAgentRequest -from google.cloud.dialogflowcx_v3.types.audio_config import InputAudioConfig -from google.cloud.dialogflowcx_v3.types.audio_config import OutputAudioConfig -from google.cloud.dialogflowcx_v3.types.audio_config import SpeechWordInfo -from google.cloud.dialogflowcx_v3.types.audio_config import SynthesizeSpeechConfig -from google.cloud.dialogflowcx_v3.types.audio_config import TextToSpeechSettings -from google.cloud.dialogflowcx_v3.types.audio_config import VoiceSelectionParams -from google.cloud.dialogflowcx_v3.types.audio_config import AudioEncoding -from google.cloud.dialogflowcx_v3.types.audio_config import OutputAudioEncoding -from google.cloud.dialogflowcx_v3.types.audio_config import SpeechModelVariant -from google.cloud.dialogflowcx_v3.types.audio_config import SsmlVoiceGender -from google.cloud.dialogflowcx_v3.types.changelog import Changelog -from google.cloud.dialogflowcx_v3.types.changelog import GetChangelogRequest -from google.cloud.dialogflowcx_v3.types.changelog import ListChangelogsRequest -from google.cloud.dialogflowcx_v3.types.changelog import ListChangelogsResponse -from google.cloud.dialogflowcx_v3.types.deployment import Deployment -from google.cloud.dialogflowcx_v3.types.deployment import GetDeploymentRequest -from google.cloud.dialogflowcx_v3.types.deployment import ListDeploymentsRequest -from google.cloud.dialogflowcx_v3.types.deployment import ListDeploymentsResponse -from google.cloud.dialogflowcx_v3.types.entity_type import CreateEntityTypeRequest -from google.cloud.dialogflowcx_v3.types.entity_type import DeleteEntityTypeRequest -from google.cloud.dialogflowcx_v3.types.entity_type import EntityType -from google.cloud.dialogflowcx_v3.types.entity_type import GetEntityTypeRequest -from google.cloud.dialogflowcx_v3.types.entity_type import ListEntityTypesRequest -from google.cloud.dialogflowcx_v3.types.entity_type import ListEntityTypesResponse -from google.cloud.dialogflowcx_v3.types.entity_type import UpdateEntityTypeRequest -from google.cloud.dialogflowcx_v3.types.environment import ContinuousTestResult -from google.cloud.dialogflowcx_v3.types.environment import CreateEnvironmentRequest -from google.cloud.dialogflowcx_v3.types.environment import DeleteEnvironmentRequest -from google.cloud.dialogflowcx_v3.types.environment import DeployFlowMetadata -from google.cloud.dialogflowcx_v3.types.environment import DeployFlowRequest -from google.cloud.dialogflowcx_v3.types.environment import DeployFlowResponse -from google.cloud.dialogflowcx_v3.types.environment import Environment -from google.cloud.dialogflowcx_v3.types.environment import GetEnvironmentRequest -from google.cloud.dialogflowcx_v3.types.environment import ListContinuousTestResultsRequest -from google.cloud.dialogflowcx_v3.types.environment import ListContinuousTestResultsResponse -from google.cloud.dialogflowcx_v3.types.environment import ListEnvironmentsRequest -from google.cloud.dialogflowcx_v3.types.environment import ListEnvironmentsResponse -from google.cloud.dialogflowcx_v3.types.environment import LookupEnvironmentHistoryRequest -from google.cloud.dialogflowcx_v3.types.environment import LookupEnvironmentHistoryResponse -from google.cloud.dialogflowcx_v3.types.environment import RunContinuousTestMetadata -from google.cloud.dialogflowcx_v3.types.environment import RunContinuousTestRequest -from google.cloud.dialogflowcx_v3.types.environment import RunContinuousTestResponse -from google.cloud.dialogflowcx_v3.types.environment import UpdateEnvironmentRequest -from google.cloud.dialogflowcx_v3.types.experiment import CreateExperimentRequest -from google.cloud.dialogflowcx_v3.types.experiment import DeleteExperimentRequest -from google.cloud.dialogflowcx_v3.types.experiment import Experiment -from google.cloud.dialogflowcx_v3.types.experiment import GetExperimentRequest -from google.cloud.dialogflowcx_v3.types.experiment import ListExperimentsRequest -from google.cloud.dialogflowcx_v3.types.experiment import ListExperimentsResponse -from google.cloud.dialogflowcx_v3.types.experiment import RolloutConfig -from google.cloud.dialogflowcx_v3.types.experiment import RolloutState -from google.cloud.dialogflowcx_v3.types.experiment import StartExperimentRequest -from google.cloud.dialogflowcx_v3.types.experiment import StopExperimentRequest -from google.cloud.dialogflowcx_v3.types.experiment import UpdateExperimentRequest -from google.cloud.dialogflowcx_v3.types.experiment import VariantsHistory -from google.cloud.dialogflowcx_v3.types.experiment import VersionVariants -from google.cloud.dialogflowcx_v3.types.flow import CreateFlowRequest -from google.cloud.dialogflowcx_v3.types.flow import DeleteFlowRequest -from google.cloud.dialogflowcx_v3.types.flow import ExportFlowRequest -from google.cloud.dialogflowcx_v3.types.flow import ExportFlowResponse -from google.cloud.dialogflowcx_v3.types.flow import Flow -from google.cloud.dialogflowcx_v3.types.flow import FlowImportStrategy -from google.cloud.dialogflowcx_v3.types.flow import FlowValidationResult -from google.cloud.dialogflowcx_v3.types.flow import GetFlowRequest -from google.cloud.dialogflowcx_v3.types.flow import GetFlowValidationResultRequest -from google.cloud.dialogflowcx_v3.types.flow import ImportFlowRequest -from google.cloud.dialogflowcx_v3.types.flow import ImportFlowResponse -from google.cloud.dialogflowcx_v3.types.flow import ListFlowsRequest -from google.cloud.dialogflowcx_v3.types.flow import ListFlowsResponse -from google.cloud.dialogflowcx_v3.types.flow import NluSettings -from google.cloud.dialogflowcx_v3.types.flow import TrainFlowRequest -from google.cloud.dialogflowcx_v3.types.flow import UpdateFlowRequest -from google.cloud.dialogflowcx_v3.types.flow import ValidateFlowRequest -from google.cloud.dialogflowcx_v3.types.fulfillment import Fulfillment -from google.cloud.dialogflowcx_v3.types.gcs import GcsDestination -from google.cloud.dialogflowcx_v3.types.import_strategy import ImportStrategy -from google.cloud.dialogflowcx_v3.types.intent import CreateIntentRequest -from google.cloud.dialogflowcx_v3.types.intent import DeleteIntentRequest -from google.cloud.dialogflowcx_v3.types.intent import GetIntentRequest -from google.cloud.dialogflowcx_v3.types.intent import Intent -from google.cloud.dialogflowcx_v3.types.intent import ListIntentsRequest -from google.cloud.dialogflowcx_v3.types.intent import ListIntentsResponse -from google.cloud.dialogflowcx_v3.types.intent import UpdateIntentRequest -from google.cloud.dialogflowcx_v3.types.intent import IntentView -from google.cloud.dialogflowcx_v3.types.page import CreatePageRequest -from google.cloud.dialogflowcx_v3.types.page import DeletePageRequest -from google.cloud.dialogflowcx_v3.types.page import EventHandler -from google.cloud.dialogflowcx_v3.types.page import Form -from google.cloud.dialogflowcx_v3.types.page import GetPageRequest -from google.cloud.dialogflowcx_v3.types.page import ListPagesRequest -from google.cloud.dialogflowcx_v3.types.page import ListPagesResponse -from google.cloud.dialogflowcx_v3.types.page import Page -from google.cloud.dialogflowcx_v3.types.page import TransitionRoute -from google.cloud.dialogflowcx_v3.types.page import UpdatePageRequest -from google.cloud.dialogflowcx_v3.types.response_message import ResponseMessage -from google.cloud.dialogflowcx_v3.types.security_settings import CreateSecuritySettingsRequest -from google.cloud.dialogflowcx_v3.types.security_settings import DeleteSecuritySettingsRequest -from google.cloud.dialogflowcx_v3.types.security_settings import GetSecuritySettingsRequest -from google.cloud.dialogflowcx_v3.types.security_settings import ListSecuritySettingsRequest -from google.cloud.dialogflowcx_v3.types.security_settings import ListSecuritySettingsResponse -from google.cloud.dialogflowcx_v3.types.security_settings import SecuritySettings -from google.cloud.dialogflowcx_v3.types.security_settings import UpdateSecuritySettingsRequest -from google.cloud.dialogflowcx_v3.types.session import AudioInput -from google.cloud.dialogflowcx_v3.types.session import CloudConversationDebuggingInfo -from google.cloud.dialogflowcx_v3.types.session import DetectIntentRequest -from google.cloud.dialogflowcx_v3.types.session import DetectIntentResponse -from google.cloud.dialogflowcx_v3.types.session import DtmfInput -from google.cloud.dialogflowcx_v3.types.session import EventInput -from google.cloud.dialogflowcx_v3.types.session import FulfillIntentRequest -from google.cloud.dialogflowcx_v3.types.session import FulfillIntentResponse -from google.cloud.dialogflowcx_v3.types.session import IntentInput -from google.cloud.dialogflowcx_v3.types.session import Match -from google.cloud.dialogflowcx_v3.types.session import MatchIntentRequest -from google.cloud.dialogflowcx_v3.types.session import MatchIntentResponse -from google.cloud.dialogflowcx_v3.types.session import QueryInput -from google.cloud.dialogflowcx_v3.types.session import QueryParameters -from google.cloud.dialogflowcx_v3.types.session import QueryResult -from google.cloud.dialogflowcx_v3.types.session import SentimentAnalysisResult -from google.cloud.dialogflowcx_v3.types.session import StreamingDetectIntentRequest -from google.cloud.dialogflowcx_v3.types.session import StreamingDetectIntentResponse -from google.cloud.dialogflowcx_v3.types.session import StreamingRecognitionResult -from google.cloud.dialogflowcx_v3.types.session import TextInput -from google.cloud.dialogflowcx_v3.types.session_entity_type import CreateSessionEntityTypeRequest -from google.cloud.dialogflowcx_v3.types.session_entity_type import DeleteSessionEntityTypeRequest -from google.cloud.dialogflowcx_v3.types.session_entity_type import GetSessionEntityTypeRequest -from google.cloud.dialogflowcx_v3.types.session_entity_type import ListSessionEntityTypesRequest -from google.cloud.dialogflowcx_v3.types.session_entity_type import ListSessionEntityTypesResponse -from google.cloud.dialogflowcx_v3.types.session_entity_type import SessionEntityType -from google.cloud.dialogflowcx_v3.types.session_entity_type import UpdateSessionEntityTypeRequest -from google.cloud.dialogflowcx_v3.types.test_case import BatchDeleteTestCasesRequest -from google.cloud.dialogflowcx_v3.types.test_case import BatchRunTestCasesMetadata -from google.cloud.dialogflowcx_v3.types.test_case import BatchRunTestCasesRequest -from google.cloud.dialogflowcx_v3.types.test_case import BatchRunTestCasesResponse -from google.cloud.dialogflowcx_v3.types.test_case import CalculateCoverageRequest -from google.cloud.dialogflowcx_v3.types.test_case import CalculateCoverageResponse -from google.cloud.dialogflowcx_v3.types.test_case import ConversationTurn -from google.cloud.dialogflowcx_v3.types.test_case import CreateTestCaseRequest -from google.cloud.dialogflowcx_v3.types.test_case import ExportTestCasesMetadata -from google.cloud.dialogflowcx_v3.types.test_case import ExportTestCasesRequest -from google.cloud.dialogflowcx_v3.types.test_case import ExportTestCasesResponse -from google.cloud.dialogflowcx_v3.types.test_case import GetTestCaseRequest -from google.cloud.dialogflowcx_v3.types.test_case import GetTestCaseResultRequest -from google.cloud.dialogflowcx_v3.types.test_case import ImportTestCasesMetadata -from google.cloud.dialogflowcx_v3.types.test_case import ImportTestCasesRequest -from google.cloud.dialogflowcx_v3.types.test_case import ImportTestCasesResponse -from google.cloud.dialogflowcx_v3.types.test_case import IntentCoverage -from google.cloud.dialogflowcx_v3.types.test_case import ListTestCaseResultsRequest -from google.cloud.dialogflowcx_v3.types.test_case import ListTestCaseResultsResponse -from google.cloud.dialogflowcx_v3.types.test_case import ListTestCasesRequest -from google.cloud.dialogflowcx_v3.types.test_case import ListTestCasesResponse -from google.cloud.dialogflowcx_v3.types.test_case import RunTestCaseMetadata -from google.cloud.dialogflowcx_v3.types.test_case import RunTestCaseRequest -from google.cloud.dialogflowcx_v3.types.test_case import RunTestCaseResponse -from google.cloud.dialogflowcx_v3.types.test_case import TestCase -from google.cloud.dialogflowcx_v3.types.test_case import TestCaseError -from google.cloud.dialogflowcx_v3.types.test_case import TestCaseResult -from google.cloud.dialogflowcx_v3.types.test_case import TestConfig -from google.cloud.dialogflowcx_v3.types.test_case import TestError -from google.cloud.dialogflowcx_v3.types.test_case import TestRunDifference -from google.cloud.dialogflowcx_v3.types.test_case import TransitionCoverage -from google.cloud.dialogflowcx_v3.types.test_case import TransitionRouteGroupCoverage -from google.cloud.dialogflowcx_v3.types.test_case import UpdateTestCaseRequest -from google.cloud.dialogflowcx_v3.types.test_case import TestResult -from google.cloud.dialogflowcx_v3.types.transition_route_group import CreateTransitionRouteGroupRequest -from google.cloud.dialogflowcx_v3.types.transition_route_group import DeleteTransitionRouteGroupRequest -from google.cloud.dialogflowcx_v3.types.transition_route_group import GetTransitionRouteGroupRequest -from google.cloud.dialogflowcx_v3.types.transition_route_group import ListTransitionRouteGroupsRequest -from google.cloud.dialogflowcx_v3.types.transition_route_group import ListTransitionRouteGroupsResponse -from google.cloud.dialogflowcx_v3.types.transition_route_group import TransitionRouteGroup -from google.cloud.dialogflowcx_v3.types.transition_route_group import UpdateTransitionRouteGroupRequest -from google.cloud.dialogflowcx_v3.types.validation_message import ResourceName -from google.cloud.dialogflowcx_v3.types.validation_message import ValidationMessage -from google.cloud.dialogflowcx_v3.types.version import CompareVersionsRequest -from google.cloud.dialogflowcx_v3.types.version import CompareVersionsResponse -from google.cloud.dialogflowcx_v3.types.version import CreateVersionOperationMetadata -from google.cloud.dialogflowcx_v3.types.version import CreateVersionRequest -from google.cloud.dialogflowcx_v3.types.version import DeleteVersionRequest -from google.cloud.dialogflowcx_v3.types.version import GetVersionRequest -from google.cloud.dialogflowcx_v3.types.version import ListVersionsRequest -from google.cloud.dialogflowcx_v3.types.version import ListVersionsResponse -from google.cloud.dialogflowcx_v3.types.version import LoadVersionRequest -from google.cloud.dialogflowcx_v3.types.version import UpdateVersionRequest -from google.cloud.dialogflowcx_v3.types.version import Version -from google.cloud.dialogflowcx_v3.types.webhook import CreateWebhookRequest -from google.cloud.dialogflowcx_v3.types.webhook import DeleteWebhookRequest -from google.cloud.dialogflowcx_v3.types.webhook import GetWebhookRequest -from google.cloud.dialogflowcx_v3.types.webhook import ListWebhooksRequest -from google.cloud.dialogflowcx_v3.types.webhook import ListWebhooksResponse -from google.cloud.dialogflowcx_v3.types.webhook import PageInfo -from google.cloud.dialogflowcx_v3.types.webhook import SessionInfo -from google.cloud.dialogflowcx_v3.types.webhook import UpdateWebhookRequest -from google.cloud.dialogflowcx_v3.types.webhook import Webhook -from google.cloud.dialogflowcx_v3.types.webhook import WebhookRequest -from google.cloud.dialogflowcx_v3.types.webhook import WebhookResponse - -__all__ = ('AgentsClient', - 'AgentsAsyncClient', - 'ChangelogsClient', - 'ChangelogsAsyncClient', - 'DeploymentsClient', - 'DeploymentsAsyncClient', - 'EntityTypesClient', - 'EntityTypesAsyncClient', - 'EnvironmentsClient', - 'EnvironmentsAsyncClient', - 'ExperimentsClient', - 'ExperimentsAsyncClient', - 'FlowsClient', - 'FlowsAsyncClient', - 'IntentsClient', - 'IntentsAsyncClient', - 'PagesClient', - 'PagesAsyncClient', - 'SecuritySettingsServiceClient', - 'SecuritySettingsServiceAsyncClient', - 'SessionEntityTypesClient', - 'SessionEntityTypesAsyncClient', - 'SessionsClient', - 'SessionsAsyncClient', - 'TestCasesClient', - 'TestCasesAsyncClient', - 'TransitionRouteGroupsClient', - 'TransitionRouteGroupsAsyncClient', - 'VersionsClient', - 'VersionsAsyncClient', - 'WebhooksClient', - 'WebhooksAsyncClient', - 'AdvancedSettings', - 'Agent', - 'AgentValidationResult', - 'CreateAgentRequest', - 'DeleteAgentRequest', - 'ExportAgentRequest', - 'ExportAgentResponse', - 'GetAgentRequest', - 'GetAgentValidationResultRequest', - 'ListAgentsRequest', - 'ListAgentsResponse', - 'RestoreAgentRequest', - 'SpeechToTextSettings', - 'UpdateAgentRequest', - 'ValidateAgentRequest', - 'InputAudioConfig', - 'OutputAudioConfig', - 'SpeechWordInfo', - 'SynthesizeSpeechConfig', - 'TextToSpeechSettings', - 'VoiceSelectionParams', - 'AudioEncoding', - 'OutputAudioEncoding', - 'SpeechModelVariant', - 'SsmlVoiceGender', - 'Changelog', - 'GetChangelogRequest', - 'ListChangelogsRequest', - 'ListChangelogsResponse', - 'Deployment', - 'GetDeploymentRequest', - 'ListDeploymentsRequest', - 'ListDeploymentsResponse', - 'CreateEntityTypeRequest', - 'DeleteEntityTypeRequest', - 'EntityType', - 'GetEntityTypeRequest', - 'ListEntityTypesRequest', - 'ListEntityTypesResponse', - 'UpdateEntityTypeRequest', - 'ContinuousTestResult', - 'CreateEnvironmentRequest', - 'DeleteEnvironmentRequest', - 'DeployFlowMetadata', - 'DeployFlowRequest', - 'DeployFlowResponse', - 'Environment', - 'GetEnvironmentRequest', - 'ListContinuousTestResultsRequest', - 'ListContinuousTestResultsResponse', - 'ListEnvironmentsRequest', - 'ListEnvironmentsResponse', - 'LookupEnvironmentHistoryRequest', - 'LookupEnvironmentHistoryResponse', - 'RunContinuousTestMetadata', - 'RunContinuousTestRequest', - 'RunContinuousTestResponse', - 'UpdateEnvironmentRequest', - 'CreateExperimentRequest', - 'DeleteExperimentRequest', - 'Experiment', - 'GetExperimentRequest', - 'ListExperimentsRequest', - 'ListExperimentsResponse', - 'RolloutConfig', - 'RolloutState', - 'StartExperimentRequest', - 'StopExperimentRequest', - 'UpdateExperimentRequest', - 'VariantsHistory', - 'VersionVariants', - 'CreateFlowRequest', - 'DeleteFlowRequest', - 'ExportFlowRequest', - 'ExportFlowResponse', - 'Flow', - 'FlowImportStrategy', - 'FlowValidationResult', - 'GetFlowRequest', - 'GetFlowValidationResultRequest', - 'ImportFlowRequest', - 'ImportFlowResponse', - 'ListFlowsRequest', - 'ListFlowsResponse', - 'NluSettings', - 'TrainFlowRequest', - 'UpdateFlowRequest', - 'ValidateFlowRequest', - 'Fulfillment', - 'GcsDestination', - 'ImportStrategy', - 'CreateIntentRequest', - 'DeleteIntentRequest', - 'GetIntentRequest', - 'Intent', - 'ListIntentsRequest', - 'ListIntentsResponse', - 'UpdateIntentRequest', - 'IntentView', - 'CreatePageRequest', - 'DeletePageRequest', - 'EventHandler', - 'Form', - 'GetPageRequest', - 'ListPagesRequest', - 'ListPagesResponse', - 'Page', - 'TransitionRoute', - 'UpdatePageRequest', - 'ResponseMessage', - 'CreateSecuritySettingsRequest', - 'DeleteSecuritySettingsRequest', - 'GetSecuritySettingsRequest', - 'ListSecuritySettingsRequest', - 'ListSecuritySettingsResponse', - 'SecuritySettings', - 'UpdateSecuritySettingsRequest', - 'AudioInput', - 'CloudConversationDebuggingInfo', - 'DetectIntentRequest', - 'DetectIntentResponse', - 'DtmfInput', - 'EventInput', - 'FulfillIntentRequest', - 'FulfillIntentResponse', - 'IntentInput', - 'Match', - 'MatchIntentRequest', - 'MatchIntentResponse', - 'QueryInput', - 'QueryParameters', - 'QueryResult', - 'SentimentAnalysisResult', - 'StreamingDetectIntentRequest', - 'StreamingDetectIntentResponse', - 'StreamingRecognitionResult', - 'TextInput', - 'CreateSessionEntityTypeRequest', - 'DeleteSessionEntityTypeRequest', - 'GetSessionEntityTypeRequest', - 'ListSessionEntityTypesRequest', - 'ListSessionEntityTypesResponse', - 'SessionEntityType', - 'UpdateSessionEntityTypeRequest', - 'BatchDeleteTestCasesRequest', - 'BatchRunTestCasesMetadata', - 'BatchRunTestCasesRequest', - 'BatchRunTestCasesResponse', - 'CalculateCoverageRequest', - 'CalculateCoverageResponse', - 'ConversationTurn', - 'CreateTestCaseRequest', - 'ExportTestCasesMetadata', - 'ExportTestCasesRequest', - 'ExportTestCasesResponse', - 'GetTestCaseRequest', - 'GetTestCaseResultRequest', - 'ImportTestCasesMetadata', - 'ImportTestCasesRequest', - 'ImportTestCasesResponse', - 'IntentCoverage', - 'ListTestCaseResultsRequest', - 'ListTestCaseResultsResponse', - 'ListTestCasesRequest', - 'ListTestCasesResponse', - 'RunTestCaseMetadata', - 'RunTestCaseRequest', - 'RunTestCaseResponse', - 'TestCase', - 'TestCaseError', - 'TestCaseResult', - 'TestConfig', - 'TestError', - 'TestRunDifference', - 'TransitionCoverage', - 'TransitionRouteGroupCoverage', - 'UpdateTestCaseRequest', - 'TestResult', - 'CreateTransitionRouteGroupRequest', - 'DeleteTransitionRouteGroupRequest', - 'GetTransitionRouteGroupRequest', - 'ListTransitionRouteGroupsRequest', - 'ListTransitionRouteGroupsResponse', - 'TransitionRouteGroup', - 'UpdateTransitionRouteGroupRequest', - 'ResourceName', - 'ValidationMessage', - 'CompareVersionsRequest', - 'CompareVersionsResponse', - 'CreateVersionOperationMetadata', - 'CreateVersionRequest', - 'DeleteVersionRequest', - 'GetVersionRequest', - 'ListVersionsRequest', - 'ListVersionsResponse', - 'LoadVersionRequest', - 'UpdateVersionRequest', - 'Version', - 'CreateWebhookRequest', - 'DeleteWebhookRequest', - 'GetWebhookRequest', - 'ListWebhooksRequest', - 'ListWebhooksResponse', - 'PageInfo', - 'SessionInfo', - 'UpdateWebhookRequest', - 'Webhook', - 'WebhookRequest', - 'WebhookResponse', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx/gapic_version.py b/owl-bot-staging/v3/google/cloud/dialogflowcx/gapic_version.py deleted file mode 100644 index 360a0d13..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx/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/v3/google/cloud/dialogflowcx/py.typed b/owl-bot-staging/v3/google/cloud/dialogflowcx/py.typed deleted file mode 100644 index e6386621..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-dialogflow-cx package uses inline types. diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/__init__.py deleted file mode 100644 index b45aa7a9..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/__init__.py +++ /dev/null @@ -1,506 +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.dialogflowcx_v3 import gapic_version as package_version - -__version__ = package_version.__version__ - - -from .services.agents import AgentsClient -from .services.agents import AgentsAsyncClient -from .services.changelogs import ChangelogsClient -from .services.changelogs import ChangelogsAsyncClient -from .services.deployments import DeploymentsClient -from .services.deployments import DeploymentsAsyncClient -from .services.entity_types import EntityTypesClient -from .services.entity_types import EntityTypesAsyncClient -from .services.environments import EnvironmentsClient -from .services.environments import EnvironmentsAsyncClient -from .services.experiments import ExperimentsClient -from .services.experiments import ExperimentsAsyncClient -from .services.flows import FlowsClient -from .services.flows import FlowsAsyncClient -from .services.intents import IntentsClient -from .services.intents import IntentsAsyncClient -from .services.pages import PagesClient -from .services.pages import PagesAsyncClient -from .services.security_settings_service import SecuritySettingsServiceClient -from .services.security_settings_service import SecuritySettingsServiceAsyncClient -from .services.session_entity_types import SessionEntityTypesClient -from .services.session_entity_types import SessionEntityTypesAsyncClient -from .services.sessions import SessionsClient -from .services.sessions import SessionsAsyncClient -from .services.test_cases import TestCasesClient -from .services.test_cases import TestCasesAsyncClient -from .services.transition_route_groups import TransitionRouteGroupsClient -from .services.transition_route_groups import TransitionRouteGroupsAsyncClient -from .services.versions import VersionsClient -from .services.versions import VersionsAsyncClient -from .services.webhooks import WebhooksClient -from .services.webhooks import WebhooksAsyncClient - -from .types.advanced_settings import AdvancedSettings -from .types.agent import Agent -from .types.agent import AgentValidationResult -from .types.agent import CreateAgentRequest -from .types.agent import DeleteAgentRequest -from .types.agent import ExportAgentRequest -from .types.agent import ExportAgentResponse -from .types.agent import GetAgentRequest -from .types.agent import GetAgentValidationResultRequest -from .types.agent import ListAgentsRequest -from .types.agent import ListAgentsResponse -from .types.agent import RestoreAgentRequest -from .types.agent import SpeechToTextSettings -from .types.agent import UpdateAgentRequest -from .types.agent import ValidateAgentRequest -from .types.audio_config import InputAudioConfig -from .types.audio_config import OutputAudioConfig -from .types.audio_config import SpeechWordInfo -from .types.audio_config import SynthesizeSpeechConfig -from .types.audio_config import TextToSpeechSettings -from .types.audio_config import VoiceSelectionParams -from .types.audio_config import AudioEncoding -from .types.audio_config import OutputAudioEncoding -from .types.audio_config import SpeechModelVariant -from .types.audio_config import SsmlVoiceGender -from .types.changelog import Changelog -from .types.changelog import GetChangelogRequest -from .types.changelog import ListChangelogsRequest -from .types.changelog import ListChangelogsResponse -from .types.deployment import Deployment -from .types.deployment import GetDeploymentRequest -from .types.deployment import ListDeploymentsRequest -from .types.deployment import ListDeploymentsResponse -from .types.entity_type import CreateEntityTypeRequest -from .types.entity_type import DeleteEntityTypeRequest -from .types.entity_type import EntityType -from .types.entity_type import GetEntityTypeRequest -from .types.entity_type import ListEntityTypesRequest -from .types.entity_type import ListEntityTypesResponse -from .types.entity_type import UpdateEntityTypeRequest -from .types.environment import ContinuousTestResult -from .types.environment import CreateEnvironmentRequest -from .types.environment import DeleteEnvironmentRequest -from .types.environment import DeployFlowMetadata -from .types.environment import DeployFlowRequest -from .types.environment import DeployFlowResponse -from .types.environment import Environment -from .types.environment import GetEnvironmentRequest -from .types.environment import ListContinuousTestResultsRequest -from .types.environment import ListContinuousTestResultsResponse -from .types.environment import ListEnvironmentsRequest -from .types.environment import ListEnvironmentsResponse -from .types.environment import LookupEnvironmentHistoryRequest -from .types.environment import LookupEnvironmentHistoryResponse -from .types.environment import RunContinuousTestMetadata -from .types.environment import RunContinuousTestRequest -from .types.environment import RunContinuousTestResponse -from .types.environment import UpdateEnvironmentRequest -from .types.experiment import CreateExperimentRequest -from .types.experiment import DeleteExperimentRequest -from .types.experiment import Experiment -from .types.experiment import GetExperimentRequest -from .types.experiment import ListExperimentsRequest -from .types.experiment import ListExperimentsResponse -from .types.experiment import RolloutConfig -from .types.experiment import RolloutState -from .types.experiment import StartExperimentRequest -from .types.experiment import StopExperimentRequest -from .types.experiment import UpdateExperimentRequest -from .types.experiment import VariantsHistory -from .types.experiment import VersionVariants -from .types.flow import CreateFlowRequest -from .types.flow import DeleteFlowRequest -from .types.flow import ExportFlowRequest -from .types.flow import ExportFlowResponse -from .types.flow import Flow -from .types.flow import FlowImportStrategy -from .types.flow import FlowValidationResult -from .types.flow import GetFlowRequest -from .types.flow import GetFlowValidationResultRequest -from .types.flow import ImportFlowRequest -from .types.flow import ImportFlowResponse -from .types.flow import ListFlowsRequest -from .types.flow import ListFlowsResponse -from .types.flow import NluSettings -from .types.flow import TrainFlowRequest -from .types.flow import UpdateFlowRequest -from .types.flow import ValidateFlowRequest -from .types.fulfillment import Fulfillment -from .types.gcs import GcsDestination -from .types.import_strategy import ImportStrategy -from .types.intent import CreateIntentRequest -from .types.intent import DeleteIntentRequest -from .types.intent import GetIntentRequest -from .types.intent import Intent -from .types.intent import ListIntentsRequest -from .types.intent import ListIntentsResponse -from .types.intent import UpdateIntentRequest -from .types.intent import IntentView -from .types.page import CreatePageRequest -from .types.page import DeletePageRequest -from .types.page import EventHandler -from .types.page import Form -from .types.page import GetPageRequest -from .types.page import ListPagesRequest -from .types.page import ListPagesResponse -from .types.page import Page -from .types.page import TransitionRoute -from .types.page import UpdatePageRequest -from .types.response_message import ResponseMessage -from .types.security_settings import CreateSecuritySettingsRequest -from .types.security_settings import DeleteSecuritySettingsRequest -from .types.security_settings import GetSecuritySettingsRequest -from .types.security_settings import ListSecuritySettingsRequest -from .types.security_settings import ListSecuritySettingsResponse -from .types.security_settings import SecuritySettings -from .types.security_settings import UpdateSecuritySettingsRequest -from .types.session import AudioInput -from .types.session import CloudConversationDebuggingInfo -from .types.session import DetectIntentRequest -from .types.session import DetectIntentResponse -from .types.session import DtmfInput -from .types.session import EventInput -from .types.session import FulfillIntentRequest -from .types.session import FulfillIntentResponse -from .types.session import IntentInput -from .types.session import Match -from .types.session import MatchIntentRequest -from .types.session import MatchIntentResponse -from .types.session import QueryInput -from .types.session import QueryParameters -from .types.session import QueryResult -from .types.session import SentimentAnalysisResult -from .types.session import StreamingDetectIntentRequest -from .types.session import StreamingDetectIntentResponse -from .types.session import StreamingRecognitionResult -from .types.session import TextInput -from .types.session_entity_type import CreateSessionEntityTypeRequest -from .types.session_entity_type import DeleteSessionEntityTypeRequest -from .types.session_entity_type import GetSessionEntityTypeRequest -from .types.session_entity_type import ListSessionEntityTypesRequest -from .types.session_entity_type import ListSessionEntityTypesResponse -from .types.session_entity_type import SessionEntityType -from .types.session_entity_type import UpdateSessionEntityTypeRequest -from .types.test_case import BatchDeleteTestCasesRequest -from .types.test_case import BatchRunTestCasesMetadata -from .types.test_case import BatchRunTestCasesRequest -from .types.test_case import BatchRunTestCasesResponse -from .types.test_case import CalculateCoverageRequest -from .types.test_case import CalculateCoverageResponse -from .types.test_case import ConversationTurn -from .types.test_case import CreateTestCaseRequest -from .types.test_case import ExportTestCasesMetadata -from .types.test_case import ExportTestCasesRequest -from .types.test_case import ExportTestCasesResponse -from .types.test_case import GetTestCaseRequest -from .types.test_case import GetTestCaseResultRequest -from .types.test_case import ImportTestCasesMetadata -from .types.test_case import ImportTestCasesRequest -from .types.test_case import ImportTestCasesResponse -from .types.test_case import IntentCoverage -from .types.test_case import ListTestCaseResultsRequest -from .types.test_case import ListTestCaseResultsResponse -from .types.test_case import ListTestCasesRequest -from .types.test_case import ListTestCasesResponse -from .types.test_case import RunTestCaseMetadata -from .types.test_case import RunTestCaseRequest -from .types.test_case import RunTestCaseResponse -from .types.test_case import TestCase -from .types.test_case import TestCaseError -from .types.test_case import TestCaseResult -from .types.test_case import TestConfig -from .types.test_case import TestError -from .types.test_case import TestRunDifference -from .types.test_case import TransitionCoverage -from .types.test_case import TransitionRouteGroupCoverage -from .types.test_case import UpdateTestCaseRequest -from .types.test_case import TestResult -from .types.transition_route_group import CreateTransitionRouteGroupRequest -from .types.transition_route_group import DeleteTransitionRouteGroupRequest -from .types.transition_route_group import GetTransitionRouteGroupRequest -from .types.transition_route_group import ListTransitionRouteGroupsRequest -from .types.transition_route_group import ListTransitionRouteGroupsResponse -from .types.transition_route_group import TransitionRouteGroup -from .types.transition_route_group import UpdateTransitionRouteGroupRequest -from .types.validation_message import ResourceName -from .types.validation_message import ValidationMessage -from .types.version import CompareVersionsRequest -from .types.version import CompareVersionsResponse -from .types.version import CreateVersionOperationMetadata -from .types.version import CreateVersionRequest -from .types.version import DeleteVersionRequest -from .types.version import GetVersionRequest -from .types.version import ListVersionsRequest -from .types.version import ListVersionsResponse -from .types.version import LoadVersionRequest -from .types.version import UpdateVersionRequest -from .types.version import Version -from .types.webhook import CreateWebhookRequest -from .types.webhook import DeleteWebhookRequest -from .types.webhook import GetWebhookRequest -from .types.webhook import ListWebhooksRequest -from .types.webhook import ListWebhooksResponse -from .types.webhook import PageInfo -from .types.webhook import SessionInfo -from .types.webhook import UpdateWebhookRequest -from .types.webhook import Webhook -from .types.webhook import WebhookRequest -from .types.webhook import WebhookResponse - -__all__ = ( - 'AgentsAsyncClient', - 'ChangelogsAsyncClient', - 'DeploymentsAsyncClient', - 'EntityTypesAsyncClient', - 'EnvironmentsAsyncClient', - 'ExperimentsAsyncClient', - 'FlowsAsyncClient', - 'IntentsAsyncClient', - 'PagesAsyncClient', - 'SecuritySettingsServiceAsyncClient', - 'SessionEntityTypesAsyncClient', - 'SessionsAsyncClient', - 'TestCasesAsyncClient', - 'TransitionRouteGroupsAsyncClient', - 'VersionsAsyncClient', - 'WebhooksAsyncClient', -'AdvancedSettings', -'Agent', -'AgentValidationResult', -'AgentsClient', -'AudioEncoding', -'AudioInput', -'BatchDeleteTestCasesRequest', -'BatchRunTestCasesMetadata', -'BatchRunTestCasesRequest', -'BatchRunTestCasesResponse', -'CalculateCoverageRequest', -'CalculateCoverageResponse', -'Changelog', -'ChangelogsClient', -'CloudConversationDebuggingInfo', -'CompareVersionsRequest', -'CompareVersionsResponse', -'ContinuousTestResult', -'ConversationTurn', -'CreateAgentRequest', -'CreateEntityTypeRequest', -'CreateEnvironmentRequest', -'CreateExperimentRequest', -'CreateFlowRequest', -'CreateIntentRequest', -'CreatePageRequest', -'CreateSecuritySettingsRequest', -'CreateSessionEntityTypeRequest', -'CreateTestCaseRequest', -'CreateTransitionRouteGroupRequest', -'CreateVersionOperationMetadata', -'CreateVersionRequest', -'CreateWebhookRequest', -'DeleteAgentRequest', -'DeleteEntityTypeRequest', -'DeleteEnvironmentRequest', -'DeleteExperimentRequest', -'DeleteFlowRequest', -'DeleteIntentRequest', -'DeletePageRequest', -'DeleteSecuritySettingsRequest', -'DeleteSessionEntityTypeRequest', -'DeleteTransitionRouteGroupRequest', -'DeleteVersionRequest', -'DeleteWebhookRequest', -'DeployFlowMetadata', -'DeployFlowRequest', -'DeployFlowResponse', -'Deployment', -'DeploymentsClient', -'DetectIntentRequest', -'DetectIntentResponse', -'DtmfInput', -'EntityType', -'EntityTypesClient', -'Environment', -'EnvironmentsClient', -'EventHandler', -'EventInput', -'Experiment', -'ExperimentsClient', -'ExportAgentRequest', -'ExportAgentResponse', -'ExportFlowRequest', -'ExportFlowResponse', -'ExportTestCasesMetadata', -'ExportTestCasesRequest', -'ExportTestCasesResponse', -'Flow', -'FlowImportStrategy', -'FlowValidationResult', -'FlowsClient', -'Form', -'FulfillIntentRequest', -'FulfillIntentResponse', -'Fulfillment', -'GcsDestination', -'GetAgentRequest', -'GetAgentValidationResultRequest', -'GetChangelogRequest', -'GetDeploymentRequest', -'GetEntityTypeRequest', -'GetEnvironmentRequest', -'GetExperimentRequest', -'GetFlowRequest', -'GetFlowValidationResultRequest', -'GetIntentRequest', -'GetPageRequest', -'GetSecuritySettingsRequest', -'GetSessionEntityTypeRequest', -'GetTestCaseRequest', -'GetTestCaseResultRequest', -'GetTransitionRouteGroupRequest', -'GetVersionRequest', -'GetWebhookRequest', -'ImportFlowRequest', -'ImportFlowResponse', -'ImportStrategy', -'ImportTestCasesMetadata', -'ImportTestCasesRequest', -'ImportTestCasesResponse', -'InputAudioConfig', -'Intent', -'IntentCoverage', -'IntentInput', -'IntentView', -'IntentsClient', -'ListAgentsRequest', -'ListAgentsResponse', -'ListChangelogsRequest', -'ListChangelogsResponse', -'ListContinuousTestResultsRequest', -'ListContinuousTestResultsResponse', -'ListDeploymentsRequest', -'ListDeploymentsResponse', -'ListEntityTypesRequest', -'ListEntityTypesResponse', -'ListEnvironmentsRequest', -'ListEnvironmentsResponse', -'ListExperimentsRequest', -'ListExperimentsResponse', -'ListFlowsRequest', -'ListFlowsResponse', -'ListIntentsRequest', -'ListIntentsResponse', -'ListPagesRequest', -'ListPagesResponse', -'ListSecuritySettingsRequest', -'ListSecuritySettingsResponse', -'ListSessionEntityTypesRequest', -'ListSessionEntityTypesResponse', -'ListTestCaseResultsRequest', -'ListTestCaseResultsResponse', -'ListTestCasesRequest', -'ListTestCasesResponse', -'ListTransitionRouteGroupsRequest', -'ListTransitionRouteGroupsResponse', -'ListVersionsRequest', -'ListVersionsResponse', -'ListWebhooksRequest', -'ListWebhooksResponse', -'LoadVersionRequest', -'LookupEnvironmentHistoryRequest', -'LookupEnvironmentHistoryResponse', -'Match', -'MatchIntentRequest', -'MatchIntentResponse', -'NluSettings', -'OutputAudioConfig', -'OutputAudioEncoding', -'Page', -'PageInfo', -'PagesClient', -'QueryInput', -'QueryParameters', -'QueryResult', -'ResourceName', -'ResponseMessage', -'RestoreAgentRequest', -'RolloutConfig', -'RolloutState', -'RunContinuousTestMetadata', -'RunContinuousTestRequest', -'RunContinuousTestResponse', -'RunTestCaseMetadata', -'RunTestCaseRequest', -'RunTestCaseResponse', -'SecuritySettings', -'SecuritySettingsServiceClient', -'SentimentAnalysisResult', -'SessionEntityType', -'SessionEntityTypesClient', -'SessionInfo', -'SessionsClient', -'SpeechModelVariant', -'SpeechToTextSettings', -'SpeechWordInfo', -'SsmlVoiceGender', -'StartExperimentRequest', -'StopExperimentRequest', -'StreamingDetectIntentRequest', -'StreamingDetectIntentResponse', -'StreamingRecognitionResult', -'SynthesizeSpeechConfig', -'TestCase', -'TestCaseError', -'TestCaseResult', -'TestCasesClient', -'TestConfig', -'TestError', -'TestResult', -'TestRunDifference', -'TextInput', -'TextToSpeechSettings', -'TrainFlowRequest', -'TransitionCoverage', -'TransitionRoute', -'TransitionRouteGroup', -'TransitionRouteGroupCoverage', -'TransitionRouteGroupsClient', -'UpdateAgentRequest', -'UpdateEntityTypeRequest', -'UpdateEnvironmentRequest', -'UpdateExperimentRequest', -'UpdateFlowRequest', -'UpdateIntentRequest', -'UpdatePageRequest', -'UpdateSecuritySettingsRequest', -'UpdateSessionEntityTypeRequest', -'UpdateTestCaseRequest', -'UpdateTransitionRouteGroupRequest', -'UpdateVersionRequest', -'UpdateWebhookRequest', -'ValidateAgentRequest', -'ValidateFlowRequest', -'ValidationMessage', -'VariantsHistory', -'Version', -'VersionVariants', -'VersionsClient', -'VoiceSelectionParams', -'Webhook', -'WebhookRequest', -'WebhookResponse', -'WebhooksClient', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/gapic_metadata.json b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/gapic_metadata.json deleted file mode 100644 index e89078c3..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/gapic_metadata.json +++ /dev/null @@ -1,1768 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.dialogflowcx_v3", - "protoPackage": "google.cloud.dialogflow.cx.v3", - "schema": "1.0", - "services": { - "Agents": { - "clients": { - "grpc": { - "libraryClient": "AgentsClient", - "rpcs": { - "CreateAgent": { - "methods": [ - "create_agent" - ] - }, - "DeleteAgent": { - "methods": [ - "delete_agent" - ] - }, - "ExportAgent": { - "methods": [ - "export_agent" - ] - }, - "GetAgent": { - "methods": [ - "get_agent" - ] - }, - "GetAgentValidationResult": { - "methods": [ - "get_agent_validation_result" - ] - }, - "ListAgents": { - "methods": [ - "list_agents" - ] - }, - "RestoreAgent": { - "methods": [ - "restore_agent" - ] - }, - "UpdateAgent": { - "methods": [ - "update_agent" - ] - }, - "ValidateAgent": { - "methods": [ - "validate_agent" - ] - } - } - }, - "grpc-async": { - "libraryClient": "AgentsAsyncClient", - "rpcs": { - "CreateAgent": { - "methods": [ - "create_agent" - ] - }, - "DeleteAgent": { - "methods": [ - "delete_agent" - ] - }, - "ExportAgent": { - "methods": [ - "export_agent" - ] - }, - "GetAgent": { - "methods": [ - "get_agent" - ] - }, - "GetAgentValidationResult": { - "methods": [ - "get_agent_validation_result" - ] - }, - "ListAgents": { - "methods": [ - "list_agents" - ] - }, - "RestoreAgent": { - "methods": [ - "restore_agent" - ] - }, - "UpdateAgent": { - "methods": [ - "update_agent" - ] - }, - "ValidateAgent": { - "methods": [ - "validate_agent" - ] - } - } - }, - "rest": { - "libraryClient": "AgentsClient", - "rpcs": { - "CreateAgent": { - "methods": [ - "create_agent" - ] - }, - "DeleteAgent": { - "methods": [ - "delete_agent" - ] - }, - "ExportAgent": { - "methods": [ - "export_agent" - ] - }, - "GetAgent": { - "methods": [ - "get_agent" - ] - }, - "GetAgentValidationResult": { - "methods": [ - "get_agent_validation_result" - ] - }, - "ListAgents": { - "methods": [ - "list_agents" - ] - }, - "RestoreAgent": { - "methods": [ - "restore_agent" - ] - }, - "UpdateAgent": { - "methods": [ - "update_agent" - ] - }, - "ValidateAgent": { - "methods": [ - "validate_agent" - ] - } - } - } - } - }, - "Changelogs": { - "clients": { - "grpc": { - "libraryClient": "ChangelogsClient", - "rpcs": { - "GetChangelog": { - "methods": [ - "get_changelog" - ] - }, - "ListChangelogs": { - "methods": [ - "list_changelogs" - ] - } - } - }, - "grpc-async": { - "libraryClient": "ChangelogsAsyncClient", - "rpcs": { - "GetChangelog": { - "methods": [ - "get_changelog" - ] - }, - "ListChangelogs": { - "methods": [ - "list_changelogs" - ] - } - } - }, - "rest": { - "libraryClient": "ChangelogsClient", - "rpcs": { - "GetChangelog": { - "methods": [ - "get_changelog" - ] - }, - "ListChangelogs": { - "methods": [ - "list_changelogs" - ] - } - } - } - } - }, - "Deployments": { - "clients": { - "grpc": { - "libraryClient": "DeploymentsClient", - "rpcs": { - "GetDeployment": { - "methods": [ - "get_deployment" - ] - }, - "ListDeployments": { - "methods": [ - "list_deployments" - ] - } - } - }, - "grpc-async": { - "libraryClient": "DeploymentsAsyncClient", - "rpcs": { - "GetDeployment": { - "methods": [ - "get_deployment" - ] - }, - "ListDeployments": { - "methods": [ - "list_deployments" - ] - } - } - }, - "rest": { - "libraryClient": "DeploymentsClient", - "rpcs": { - "GetDeployment": { - "methods": [ - "get_deployment" - ] - }, - "ListDeployments": { - "methods": [ - "list_deployments" - ] - } - } - } - } - }, - "EntityTypes": { - "clients": { - "grpc": { - "libraryClient": "EntityTypesClient", - "rpcs": { - "CreateEntityType": { - "methods": [ - "create_entity_type" - ] - }, - "DeleteEntityType": { - "methods": [ - "delete_entity_type" - ] - }, - "GetEntityType": { - "methods": [ - "get_entity_type" - ] - }, - "ListEntityTypes": { - "methods": [ - "list_entity_types" - ] - }, - "UpdateEntityType": { - "methods": [ - "update_entity_type" - ] - } - } - }, - "grpc-async": { - "libraryClient": "EntityTypesAsyncClient", - "rpcs": { - "CreateEntityType": { - "methods": [ - "create_entity_type" - ] - }, - "DeleteEntityType": { - "methods": [ - "delete_entity_type" - ] - }, - "GetEntityType": { - "methods": [ - "get_entity_type" - ] - }, - "ListEntityTypes": { - "methods": [ - "list_entity_types" - ] - }, - "UpdateEntityType": { - "methods": [ - "update_entity_type" - ] - } - } - }, - "rest": { - "libraryClient": "EntityTypesClient", - "rpcs": { - "CreateEntityType": { - "methods": [ - "create_entity_type" - ] - }, - "DeleteEntityType": { - "methods": [ - "delete_entity_type" - ] - }, - "GetEntityType": { - "methods": [ - "get_entity_type" - ] - }, - "ListEntityTypes": { - "methods": [ - "list_entity_types" - ] - }, - "UpdateEntityType": { - "methods": [ - "update_entity_type" - ] - } - } - } - } - }, - "Environments": { - "clients": { - "grpc": { - "libraryClient": "EnvironmentsClient", - "rpcs": { - "CreateEnvironment": { - "methods": [ - "create_environment" - ] - }, - "DeleteEnvironment": { - "methods": [ - "delete_environment" - ] - }, - "DeployFlow": { - "methods": [ - "deploy_flow" - ] - }, - "GetEnvironment": { - "methods": [ - "get_environment" - ] - }, - "ListContinuousTestResults": { - "methods": [ - "list_continuous_test_results" - ] - }, - "ListEnvironments": { - "methods": [ - "list_environments" - ] - }, - "LookupEnvironmentHistory": { - "methods": [ - "lookup_environment_history" - ] - }, - "RunContinuousTest": { - "methods": [ - "run_continuous_test" - ] - }, - "UpdateEnvironment": { - "methods": [ - "update_environment" - ] - } - } - }, - "grpc-async": { - "libraryClient": "EnvironmentsAsyncClient", - "rpcs": { - "CreateEnvironment": { - "methods": [ - "create_environment" - ] - }, - "DeleteEnvironment": { - "methods": [ - "delete_environment" - ] - }, - "DeployFlow": { - "methods": [ - "deploy_flow" - ] - }, - "GetEnvironment": { - "methods": [ - "get_environment" - ] - }, - "ListContinuousTestResults": { - "methods": [ - "list_continuous_test_results" - ] - }, - "ListEnvironments": { - "methods": [ - "list_environments" - ] - }, - "LookupEnvironmentHistory": { - "methods": [ - "lookup_environment_history" - ] - }, - "RunContinuousTest": { - "methods": [ - "run_continuous_test" - ] - }, - "UpdateEnvironment": { - "methods": [ - "update_environment" - ] - } - } - }, - "rest": { - "libraryClient": "EnvironmentsClient", - "rpcs": { - "CreateEnvironment": { - "methods": [ - "create_environment" - ] - }, - "DeleteEnvironment": { - "methods": [ - "delete_environment" - ] - }, - "DeployFlow": { - "methods": [ - "deploy_flow" - ] - }, - "GetEnvironment": { - "methods": [ - "get_environment" - ] - }, - "ListContinuousTestResults": { - "methods": [ - "list_continuous_test_results" - ] - }, - "ListEnvironments": { - "methods": [ - "list_environments" - ] - }, - "LookupEnvironmentHistory": { - "methods": [ - "lookup_environment_history" - ] - }, - "RunContinuousTest": { - "methods": [ - "run_continuous_test" - ] - }, - "UpdateEnvironment": { - "methods": [ - "update_environment" - ] - } - } - } - } - }, - "Experiments": { - "clients": { - "grpc": { - "libraryClient": "ExperimentsClient", - "rpcs": { - "CreateExperiment": { - "methods": [ - "create_experiment" - ] - }, - "DeleteExperiment": { - "methods": [ - "delete_experiment" - ] - }, - "GetExperiment": { - "methods": [ - "get_experiment" - ] - }, - "ListExperiments": { - "methods": [ - "list_experiments" - ] - }, - "StartExperiment": { - "methods": [ - "start_experiment" - ] - }, - "StopExperiment": { - "methods": [ - "stop_experiment" - ] - }, - "UpdateExperiment": { - "methods": [ - "update_experiment" - ] - } - } - }, - "grpc-async": { - "libraryClient": "ExperimentsAsyncClient", - "rpcs": { - "CreateExperiment": { - "methods": [ - "create_experiment" - ] - }, - "DeleteExperiment": { - "methods": [ - "delete_experiment" - ] - }, - "GetExperiment": { - "methods": [ - "get_experiment" - ] - }, - "ListExperiments": { - "methods": [ - "list_experiments" - ] - }, - "StartExperiment": { - "methods": [ - "start_experiment" - ] - }, - "StopExperiment": { - "methods": [ - "stop_experiment" - ] - }, - "UpdateExperiment": { - "methods": [ - "update_experiment" - ] - } - } - }, - "rest": { - "libraryClient": "ExperimentsClient", - "rpcs": { - "CreateExperiment": { - "methods": [ - "create_experiment" - ] - }, - "DeleteExperiment": { - "methods": [ - "delete_experiment" - ] - }, - "GetExperiment": { - "methods": [ - "get_experiment" - ] - }, - "ListExperiments": { - "methods": [ - "list_experiments" - ] - }, - "StartExperiment": { - "methods": [ - "start_experiment" - ] - }, - "StopExperiment": { - "methods": [ - "stop_experiment" - ] - }, - "UpdateExperiment": { - "methods": [ - "update_experiment" - ] - } - } - } - } - }, - "Flows": { - "clients": { - "grpc": { - "libraryClient": "FlowsClient", - "rpcs": { - "CreateFlow": { - "methods": [ - "create_flow" - ] - }, - "DeleteFlow": { - "methods": [ - "delete_flow" - ] - }, - "ExportFlow": { - "methods": [ - "export_flow" - ] - }, - "GetFlow": { - "methods": [ - "get_flow" - ] - }, - "GetFlowValidationResult": { - "methods": [ - "get_flow_validation_result" - ] - }, - "ImportFlow": { - "methods": [ - "import_flow" - ] - }, - "ListFlows": { - "methods": [ - "list_flows" - ] - }, - "TrainFlow": { - "methods": [ - "train_flow" - ] - }, - "UpdateFlow": { - "methods": [ - "update_flow" - ] - }, - "ValidateFlow": { - "methods": [ - "validate_flow" - ] - } - } - }, - "grpc-async": { - "libraryClient": "FlowsAsyncClient", - "rpcs": { - "CreateFlow": { - "methods": [ - "create_flow" - ] - }, - "DeleteFlow": { - "methods": [ - "delete_flow" - ] - }, - "ExportFlow": { - "methods": [ - "export_flow" - ] - }, - "GetFlow": { - "methods": [ - "get_flow" - ] - }, - "GetFlowValidationResult": { - "methods": [ - "get_flow_validation_result" - ] - }, - "ImportFlow": { - "methods": [ - "import_flow" - ] - }, - "ListFlows": { - "methods": [ - "list_flows" - ] - }, - "TrainFlow": { - "methods": [ - "train_flow" - ] - }, - "UpdateFlow": { - "methods": [ - "update_flow" - ] - }, - "ValidateFlow": { - "methods": [ - "validate_flow" - ] - } - } - }, - "rest": { - "libraryClient": "FlowsClient", - "rpcs": { - "CreateFlow": { - "methods": [ - "create_flow" - ] - }, - "DeleteFlow": { - "methods": [ - "delete_flow" - ] - }, - "ExportFlow": { - "methods": [ - "export_flow" - ] - }, - "GetFlow": { - "methods": [ - "get_flow" - ] - }, - "GetFlowValidationResult": { - "methods": [ - "get_flow_validation_result" - ] - }, - "ImportFlow": { - "methods": [ - "import_flow" - ] - }, - "ListFlows": { - "methods": [ - "list_flows" - ] - }, - "TrainFlow": { - "methods": [ - "train_flow" - ] - }, - "UpdateFlow": { - "methods": [ - "update_flow" - ] - }, - "ValidateFlow": { - "methods": [ - "validate_flow" - ] - } - } - } - } - }, - "Intents": { - "clients": { - "grpc": { - "libraryClient": "IntentsClient", - "rpcs": { - "CreateIntent": { - "methods": [ - "create_intent" - ] - }, - "DeleteIntent": { - "methods": [ - "delete_intent" - ] - }, - "GetIntent": { - "methods": [ - "get_intent" - ] - }, - "ListIntents": { - "methods": [ - "list_intents" - ] - }, - "UpdateIntent": { - "methods": [ - "update_intent" - ] - } - } - }, - "grpc-async": { - "libraryClient": "IntentsAsyncClient", - "rpcs": { - "CreateIntent": { - "methods": [ - "create_intent" - ] - }, - "DeleteIntent": { - "methods": [ - "delete_intent" - ] - }, - "GetIntent": { - "methods": [ - "get_intent" - ] - }, - "ListIntents": { - "methods": [ - "list_intents" - ] - }, - "UpdateIntent": { - "methods": [ - "update_intent" - ] - } - } - }, - "rest": { - "libraryClient": "IntentsClient", - "rpcs": { - "CreateIntent": { - "methods": [ - "create_intent" - ] - }, - "DeleteIntent": { - "methods": [ - "delete_intent" - ] - }, - "GetIntent": { - "methods": [ - "get_intent" - ] - }, - "ListIntents": { - "methods": [ - "list_intents" - ] - }, - "UpdateIntent": { - "methods": [ - "update_intent" - ] - } - } - } - } - }, - "Pages": { - "clients": { - "grpc": { - "libraryClient": "PagesClient", - "rpcs": { - "CreatePage": { - "methods": [ - "create_page" - ] - }, - "DeletePage": { - "methods": [ - "delete_page" - ] - }, - "GetPage": { - "methods": [ - "get_page" - ] - }, - "ListPages": { - "methods": [ - "list_pages" - ] - }, - "UpdatePage": { - "methods": [ - "update_page" - ] - } - } - }, - "grpc-async": { - "libraryClient": "PagesAsyncClient", - "rpcs": { - "CreatePage": { - "methods": [ - "create_page" - ] - }, - "DeletePage": { - "methods": [ - "delete_page" - ] - }, - "GetPage": { - "methods": [ - "get_page" - ] - }, - "ListPages": { - "methods": [ - "list_pages" - ] - }, - "UpdatePage": { - "methods": [ - "update_page" - ] - } - } - }, - "rest": { - "libraryClient": "PagesClient", - "rpcs": { - "CreatePage": { - "methods": [ - "create_page" - ] - }, - "DeletePage": { - "methods": [ - "delete_page" - ] - }, - "GetPage": { - "methods": [ - "get_page" - ] - }, - "ListPages": { - "methods": [ - "list_pages" - ] - }, - "UpdatePage": { - "methods": [ - "update_page" - ] - } - } - } - } - }, - "SecuritySettingsService": { - "clients": { - "grpc": { - "libraryClient": "SecuritySettingsServiceClient", - "rpcs": { - "CreateSecuritySettings": { - "methods": [ - "create_security_settings" - ] - }, - "DeleteSecuritySettings": { - "methods": [ - "delete_security_settings" - ] - }, - "GetSecuritySettings": { - "methods": [ - "get_security_settings" - ] - }, - "ListSecuritySettings": { - "methods": [ - "list_security_settings" - ] - }, - "UpdateSecuritySettings": { - "methods": [ - "update_security_settings" - ] - } - } - }, - "grpc-async": { - "libraryClient": "SecuritySettingsServiceAsyncClient", - "rpcs": { - "CreateSecuritySettings": { - "methods": [ - "create_security_settings" - ] - }, - "DeleteSecuritySettings": { - "methods": [ - "delete_security_settings" - ] - }, - "GetSecuritySettings": { - "methods": [ - "get_security_settings" - ] - }, - "ListSecuritySettings": { - "methods": [ - "list_security_settings" - ] - }, - "UpdateSecuritySettings": { - "methods": [ - "update_security_settings" - ] - } - } - }, - "rest": { - "libraryClient": "SecuritySettingsServiceClient", - "rpcs": { - "CreateSecuritySettings": { - "methods": [ - "create_security_settings" - ] - }, - "DeleteSecuritySettings": { - "methods": [ - "delete_security_settings" - ] - }, - "GetSecuritySettings": { - "methods": [ - "get_security_settings" - ] - }, - "ListSecuritySettings": { - "methods": [ - "list_security_settings" - ] - }, - "UpdateSecuritySettings": { - "methods": [ - "update_security_settings" - ] - } - } - } - } - }, - "SessionEntityTypes": { - "clients": { - "grpc": { - "libraryClient": "SessionEntityTypesClient", - "rpcs": { - "CreateSessionEntityType": { - "methods": [ - "create_session_entity_type" - ] - }, - "DeleteSessionEntityType": { - "methods": [ - "delete_session_entity_type" - ] - }, - "GetSessionEntityType": { - "methods": [ - "get_session_entity_type" - ] - }, - "ListSessionEntityTypes": { - "methods": [ - "list_session_entity_types" - ] - }, - "UpdateSessionEntityType": { - "methods": [ - "update_session_entity_type" - ] - } - } - }, - "grpc-async": { - "libraryClient": "SessionEntityTypesAsyncClient", - "rpcs": { - "CreateSessionEntityType": { - "methods": [ - "create_session_entity_type" - ] - }, - "DeleteSessionEntityType": { - "methods": [ - "delete_session_entity_type" - ] - }, - "GetSessionEntityType": { - "methods": [ - "get_session_entity_type" - ] - }, - "ListSessionEntityTypes": { - "methods": [ - "list_session_entity_types" - ] - }, - "UpdateSessionEntityType": { - "methods": [ - "update_session_entity_type" - ] - } - } - }, - "rest": { - "libraryClient": "SessionEntityTypesClient", - "rpcs": { - "CreateSessionEntityType": { - "methods": [ - "create_session_entity_type" - ] - }, - "DeleteSessionEntityType": { - "methods": [ - "delete_session_entity_type" - ] - }, - "GetSessionEntityType": { - "methods": [ - "get_session_entity_type" - ] - }, - "ListSessionEntityTypes": { - "methods": [ - "list_session_entity_types" - ] - }, - "UpdateSessionEntityType": { - "methods": [ - "update_session_entity_type" - ] - } - } - } - } - }, - "Sessions": { - "clients": { - "grpc": { - "libraryClient": "SessionsClient", - "rpcs": { - "DetectIntent": { - "methods": [ - "detect_intent" - ] - }, - "FulfillIntent": { - "methods": [ - "fulfill_intent" - ] - }, - "MatchIntent": { - "methods": [ - "match_intent" - ] - }, - "StreamingDetectIntent": { - "methods": [ - "streaming_detect_intent" - ] - } - } - }, - "grpc-async": { - "libraryClient": "SessionsAsyncClient", - "rpcs": { - "DetectIntent": { - "methods": [ - "detect_intent" - ] - }, - "FulfillIntent": { - "methods": [ - "fulfill_intent" - ] - }, - "MatchIntent": { - "methods": [ - "match_intent" - ] - }, - "StreamingDetectIntent": { - "methods": [ - "streaming_detect_intent" - ] - } - } - }, - "rest": { - "libraryClient": "SessionsClient", - "rpcs": { - "DetectIntent": { - "methods": [ - "detect_intent" - ] - }, - "FulfillIntent": { - "methods": [ - "fulfill_intent" - ] - }, - "MatchIntent": { - "methods": [ - "match_intent" - ] - }, - "StreamingDetectIntent": { - "methods": [ - "streaming_detect_intent" - ] - } - } - } - } - }, - "TestCases": { - "clients": { - "grpc": { - "libraryClient": "TestCasesClient", - "rpcs": { - "BatchDeleteTestCases": { - "methods": [ - "batch_delete_test_cases" - ] - }, - "BatchRunTestCases": { - "methods": [ - "batch_run_test_cases" - ] - }, - "CalculateCoverage": { - "methods": [ - "calculate_coverage" - ] - }, - "CreateTestCase": { - "methods": [ - "create_test_case" - ] - }, - "ExportTestCases": { - "methods": [ - "export_test_cases" - ] - }, - "GetTestCase": { - "methods": [ - "get_test_case" - ] - }, - "GetTestCaseResult": { - "methods": [ - "get_test_case_result" - ] - }, - "ImportTestCases": { - "methods": [ - "import_test_cases" - ] - }, - "ListTestCaseResults": { - "methods": [ - "list_test_case_results" - ] - }, - "ListTestCases": { - "methods": [ - "list_test_cases" - ] - }, - "RunTestCase": { - "methods": [ - "run_test_case" - ] - }, - "UpdateTestCase": { - "methods": [ - "update_test_case" - ] - } - } - }, - "grpc-async": { - "libraryClient": "TestCasesAsyncClient", - "rpcs": { - "BatchDeleteTestCases": { - "methods": [ - "batch_delete_test_cases" - ] - }, - "BatchRunTestCases": { - "methods": [ - "batch_run_test_cases" - ] - }, - "CalculateCoverage": { - "methods": [ - "calculate_coverage" - ] - }, - "CreateTestCase": { - "methods": [ - "create_test_case" - ] - }, - "ExportTestCases": { - "methods": [ - "export_test_cases" - ] - }, - "GetTestCase": { - "methods": [ - "get_test_case" - ] - }, - "GetTestCaseResult": { - "methods": [ - "get_test_case_result" - ] - }, - "ImportTestCases": { - "methods": [ - "import_test_cases" - ] - }, - "ListTestCaseResults": { - "methods": [ - "list_test_case_results" - ] - }, - "ListTestCases": { - "methods": [ - "list_test_cases" - ] - }, - "RunTestCase": { - "methods": [ - "run_test_case" - ] - }, - "UpdateTestCase": { - "methods": [ - "update_test_case" - ] - } - } - }, - "rest": { - "libraryClient": "TestCasesClient", - "rpcs": { - "BatchDeleteTestCases": { - "methods": [ - "batch_delete_test_cases" - ] - }, - "BatchRunTestCases": { - "methods": [ - "batch_run_test_cases" - ] - }, - "CalculateCoverage": { - "methods": [ - "calculate_coverage" - ] - }, - "CreateTestCase": { - "methods": [ - "create_test_case" - ] - }, - "ExportTestCases": { - "methods": [ - "export_test_cases" - ] - }, - "GetTestCase": { - "methods": [ - "get_test_case" - ] - }, - "GetTestCaseResult": { - "methods": [ - "get_test_case_result" - ] - }, - "ImportTestCases": { - "methods": [ - "import_test_cases" - ] - }, - "ListTestCaseResults": { - "methods": [ - "list_test_case_results" - ] - }, - "ListTestCases": { - "methods": [ - "list_test_cases" - ] - }, - "RunTestCase": { - "methods": [ - "run_test_case" - ] - }, - "UpdateTestCase": { - "methods": [ - "update_test_case" - ] - } - } - } - } - }, - "TransitionRouteGroups": { - "clients": { - "grpc": { - "libraryClient": "TransitionRouteGroupsClient", - "rpcs": { - "CreateTransitionRouteGroup": { - "methods": [ - "create_transition_route_group" - ] - }, - "DeleteTransitionRouteGroup": { - "methods": [ - "delete_transition_route_group" - ] - }, - "GetTransitionRouteGroup": { - "methods": [ - "get_transition_route_group" - ] - }, - "ListTransitionRouteGroups": { - "methods": [ - "list_transition_route_groups" - ] - }, - "UpdateTransitionRouteGroup": { - "methods": [ - "update_transition_route_group" - ] - } - } - }, - "grpc-async": { - "libraryClient": "TransitionRouteGroupsAsyncClient", - "rpcs": { - "CreateTransitionRouteGroup": { - "methods": [ - "create_transition_route_group" - ] - }, - "DeleteTransitionRouteGroup": { - "methods": [ - "delete_transition_route_group" - ] - }, - "GetTransitionRouteGroup": { - "methods": [ - "get_transition_route_group" - ] - }, - "ListTransitionRouteGroups": { - "methods": [ - "list_transition_route_groups" - ] - }, - "UpdateTransitionRouteGroup": { - "methods": [ - "update_transition_route_group" - ] - } - } - }, - "rest": { - "libraryClient": "TransitionRouteGroupsClient", - "rpcs": { - "CreateTransitionRouteGroup": { - "methods": [ - "create_transition_route_group" - ] - }, - "DeleteTransitionRouteGroup": { - "methods": [ - "delete_transition_route_group" - ] - }, - "GetTransitionRouteGroup": { - "methods": [ - "get_transition_route_group" - ] - }, - "ListTransitionRouteGroups": { - "methods": [ - "list_transition_route_groups" - ] - }, - "UpdateTransitionRouteGroup": { - "methods": [ - "update_transition_route_group" - ] - } - } - } - } - }, - "Versions": { - "clients": { - "grpc": { - "libraryClient": "VersionsClient", - "rpcs": { - "CompareVersions": { - "methods": [ - "compare_versions" - ] - }, - "CreateVersion": { - "methods": [ - "create_version" - ] - }, - "DeleteVersion": { - "methods": [ - "delete_version" - ] - }, - "GetVersion": { - "methods": [ - "get_version" - ] - }, - "ListVersions": { - "methods": [ - "list_versions" - ] - }, - "LoadVersion": { - "methods": [ - "load_version" - ] - }, - "UpdateVersion": { - "methods": [ - "update_version" - ] - } - } - }, - "grpc-async": { - "libraryClient": "VersionsAsyncClient", - "rpcs": { - "CompareVersions": { - "methods": [ - "compare_versions" - ] - }, - "CreateVersion": { - "methods": [ - "create_version" - ] - }, - "DeleteVersion": { - "methods": [ - "delete_version" - ] - }, - "GetVersion": { - "methods": [ - "get_version" - ] - }, - "ListVersions": { - "methods": [ - "list_versions" - ] - }, - "LoadVersion": { - "methods": [ - "load_version" - ] - }, - "UpdateVersion": { - "methods": [ - "update_version" - ] - } - } - }, - "rest": { - "libraryClient": "VersionsClient", - "rpcs": { - "CompareVersions": { - "methods": [ - "compare_versions" - ] - }, - "CreateVersion": { - "methods": [ - "create_version" - ] - }, - "DeleteVersion": { - "methods": [ - "delete_version" - ] - }, - "GetVersion": { - "methods": [ - "get_version" - ] - }, - "ListVersions": { - "methods": [ - "list_versions" - ] - }, - "LoadVersion": { - "methods": [ - "load_version" - ] - }, - "UpdateVersion": { - "methods": [ - "update_version" - ] - } - } - } - } - }, - "Webhooks": { - "clients": { - "grpc": { - "libraryClient": "WebhooksClient", - "rpcs": { - "CreateWebhook": { - "methods": [ - "create_webhook" - ] - }, - "DeleteWebhook": { - "methods": [ - "delete_webhook" - ] - }, - "GetWebhook": { - "methods": [ - "get_webhook" - ] - }, - "ListWebhooks": { - "methods": [ - "list_webhooks" - ] - }, - "UpdateWebhook": { - "methods": [ - "update_webhook" - ] - } - } - }, - "grpc-async": { - "libraryClient": "WebhooksAsyncClient", - "rpcs": { - "CreateWebhook": { - "methods": [ - "create_webhook" - ] - }, - "DeleteWebhook": { - "methods": [ - "delete_webhook" - ] - }, - "GetWebhook": { - "methods": [ - "get_webhook" - ] - }, - "ListWebhooks": { - "methods": [ - "list_webhooks" - ] - }, - "UpdateWebhook": { - "methods": [ - "update_webhook" - ] - } - } - }, - "rest": { - "libraryClient": "WebhooksClient", - "rpcs": { - "CreateWebhook": { - "methods": [ - "create_webhook" - ] - }, - "DeleteWebhook": { - "methods": [ - "delete_webhook" - ] - }, - "GetWebhook": { - "methods": [ - "get_webhook" - ] - }, - "ListWebhooks": { - "methods": [ - "list_webhooks" - ] - }, - "UpdateWebhook": { - "methods": [ - "update_webhook" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/gapic_version.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/gapic_version.py deleted file mode 100644 index 360a0d13..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/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/v3/google/cloud/dialogflowcx_v3/py.typed b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/py.typed deleted file mode 100644 index e6386621..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-dialogflow-cx package uses inline types. diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/__init__.py deleted file mode 100644 index 89a37dc9..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/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/v3/google/cloud/dialogflowcx_v3/services/agents/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/__init__.py deleted file mode 100644 index 917b0a94..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/__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 AgentsClient -from .async_client import AgentsAsyncClient - -__all__ = ( - 'AgentsClient', - 'AgentsAsyncClient', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/async_client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/async_client.py deleted file mode 100644 index d4c636c0..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/async_client.py +++ /dev/null @@ -1,1474 +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.dialogflowcx_v3 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.dialogflowcx_v3.services.agents import pagers -from google.cloud.dialogflowcx_v3.types import advanced_settings -from google.cloud.dialogflowcx_v3.types import agent -from google.cloud.dialogflowcx_v3.types import agent as gcdc_agent -from google.cloud.dialogflowcx_v3.types import audio_config -from google.cloud.dialogflowcx_v3.types import flow -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import struct_pb2 # type: ignore -from .transports.base import AgentsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import AgentsGrpcAsyncIOTransport -from .client import AgentsClient - - -class AgentsAsyncClient: - """Service for managing [Agents][google.cloud.dialogflow.cx.v3.Agent].""" - - _client: AgentsClient - - DEFAULT_ENDPOINT = AgentsClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = AgentsClient.DEFAULT_MTLS_ENDPOINT - - agent_path = staticmethod(AgentsClient.agent_path) - parse_agent_path = staticmethod(AgentsClient.parse_agent_path) - agent_validation_result_path = staticmethod(AgentsClient.agent_validation_result_path) - parse_agent_validation_result_path = staticmethod(AgentsClient.parse_agent_validation_result_path) - environment_path = staticmethod(AgentsClient.environment_path) - parse_environment_path = staticmethod(AgentsClient.parse_environment_path) - flow_path = staticmethod(AgentsClient.flow_path) - parse_flow_path = staticmethod(AgentsClient.parse_flow_path) - flow_validation_result_path = staticmethod(AgentsClient.flow_validation_result_path) - parse_flow_validation_result_path = staticmethod(AgentsClient.parse_flow_validation_result_path) - security_settings_path = staticmethod(AgentsClient.security_settings_path) - parse_security_settings_path = staticmethod(AgentsClient.parse_security_settings_path) - common_billing_account_path = staticmethod(AgentsClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(AgentsClient.parse_common_billing_account_path) - common_folder_path = staticmethod(AgentsClient.common_folder_path) - parse_common_folder_path = staticmethod(AgentsClient.parse_common_folder_path) - common_organization_path = staticmethod(AgentsClient.common_organization_path) - parse_common_organization_path = staticmethod(AgentsClient.parse_common_organization_path) - common_project_path = staticmethod(AgentsClient.common_project_path) - parse_common_project_path = staticmethod(AgentsClient.parse_common_project_path) - common_location_path = staticmethod(AgentsClient.common_location_path) - parse_common_location_path = staticmethod(AgentsClient.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: - AgentsAsyncClient: The constructed client. - """ - return AgentsClient.from_service_account_info.__func__(AgentsAsyncClient, 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: - AgentsAsyncClient: The constructed client. - """ - return AgentsClient.from_service_account_file.__func__(AgentsAsyncClient, 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 AgentsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> AgentsTransport: - """Returns the transport used by the client instance. - - Returns: - AgentsTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(AgentsClient).get_transport_class, type(AgentsClient)) - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, AgentsTransport] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the agents 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, ~.AgentsTransport]): 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 = AgentsClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def list_agents(self, - request: Optional[Union[agent.ListAgentsRequest, 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.ListAgentsAsyncPager: - r"""Returns the list of all agents in the specified - location. - - .. 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 dialogflowcx_v3 - - async def sample_list_agents(): - # Create a client - client = dialogflowcx_v3.AgentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListAgentsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_agents(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ListAgentsRequest, dict]]): - The request object. The request message for - [Agents.ListAgents][google.cloud.dialogflow.cx.v3.Agents.ListAgents]. - parent (:class:`str`): - Required. The location to list all agents for. Format: - ``projects//locations/``. - - 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.dialogflowcx_v3.services.agents.pagers.ListAgentsAsyncPager: - The response message for - [Agents.ListAgents][google.cloud.dialogflow.cx.v3.Agents.ListAgents]. - - 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 = agent.ListAgentsRequest(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_agents, - 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.ListAgentsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_agent(self, - request: Optional[Union[agent.GetAgentRequest, 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]] = (), - ) -> agent.Agent: - r"""Retrieves the specified agent. - - .. 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 dialogflowcx_v3 - - async def sample_get_agent(): - # Create a client - client = dialogflowcx_v3.AgentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetAgentRequest( - name="name_value", - ) - - # Make the request - response = await client.get_agent(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.GetAgentRequest, dict]]): - The request object. The request message for - [Agents.GetAgent][google.cloud.dialogflow.cx.v3.Agents.GetAgent]. - name (:class:`str`): - Required. The name of the agent. Format: - ``projects//locations//agents/``. - - 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.dialogflowcx_v3.types.Agent: - Agents are best described as Natural Language Understanding (NLU) modules - that transform user requests into actionable data. - You can include agents in your app, product, or - service to determine user intent and respond to the - user in a natural way. - - After you create an agent, you can add - [Intents][google.cloud.dialogflow.cx.v3.Intent], - [Entity - Types][google.cloud.dialogflow.cx.v3.EntityType], - [Flows][google.cloud.dialogflow.cx.v3.Flow], - [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment], - [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], - [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - and so on to manage the conversation flows. - - """ - # 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 = agent.GetAgentRequest(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_agent, - 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 create_agent(self, - request: Optional[Union[gcdc_agent.CreateAgentRequest, dict]] = None, - *, - parent: Optional[str] = None, - agent: Optional[gcdc_agent.Agent] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_agent.Agent: - r"""Creates an agent in the specified location. - - Note: You should always train flows prior to sending them - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - async def sample_create_agent(): - # Create a client - client = dialogflowcx_v3.AgentsAsyncClient() - - # Initialize request argument(s) - agent = dialogflowcx_v3.Agent() - agent.display_name = "display_name_value" - agent.default_language_code = "default_language_code_value" - agent.time_zone = "time_zone_value" - - request = dialogflowcx_v3.CreateAgentRequest( - parent="parent_value", - agent=agent, - ) - - # Make the request - response = await client.create_agent(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.CreateAgentRequest, dict]]): - The request object. The request message for - [Agents.CreateAgent][google.cloud.dialogflow.cx.v3.Agents.CreateAgent]. - parent (:class:`str`): - Required. The location to create a agent for. Format: - ``projects//locations/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - agent (:class:`google.cloud.dialogflowcx_v3.types.Agent`): - Required. The agent to create. - This corresponds to the ``agent`` 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.dialogflowcx_v3.types.Agent: - Agents are best described as Natural Language Understanding (NLU) modules - that transform user requests into actionable data. - You can include agents in your app, product, or - service to determine user intent and respond to the - user in a natural way. - - After you create an agent, you can add - [Intents][google.cloud.dialogflow.cx.v3.Intent], - [Entity - Types][google.cloud.dialogflow.cx.v3.EntityType], - [Flows][google.cloud.dialogflow.cx.v3.Flow], - [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment], - [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], - [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - and so on to manage the conversation flows. - - """ - # 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, agent]) - 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 = gcdc_agent.CreateAgentRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if agent is not None: - request.agent = agent - - # 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_agent, - default_retry=retries.Retry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=180.0, - ), - default_timeout=180.0, - 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_agent(self, - request: Optional[Union[gcdc_agent.UpdateAgentRequest, dict]] = None, - *, - agent: Optional[gcdc_agent.Agent] = 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]] = (), - ) -> gcdc_agent.Agent: - r"""Updates the specified agent. - - Note: You should always train flows prior to sending them - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - async def sample_update_agent(): - # Create a client - client = dialogflowcx_v3.AgentsAsyncClient() - - # Initialize request argument(s) - agent = dialogflowcx_v3.Agent() - agent.display_name = "display_name_value" - agent.default_language_code = "default_language_code_value" - agent.time_zone = "time_zone_value" - - request = dialogflowcx_v3.UpdateAgentRequest( - agent=agent, - ) - - # Make the request - response = await client.update_agent(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.UpdateAgentRequest, dict]]): - The request object. The request message for - [Agents.UpdateAgent][google.cloud.dialogflow.cx.v3.Agents.UpdateAgent]. - agent (:class:`google.cloud.dialogflowcx_v3.types.Agent`): - Required. The agent to update. - This corresponds to the ``agent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The mask to control which fields get - updated. If the mask is not present, all - fields will 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.dialogflowcx_v3.types.Agent: - Agents are best described as Natural Language Understanding (NLU) modules - that transform user requests into actionable data. - You can include agents in your app, product, or - service to determine user intent and respond to the - user in a natural way. - - After you create an agent, you can add - [Intents][google.cloud.dialogflow.cx.v3.Intent], - [Entity - Types][google.cloud.dialogflow.cx.v3.EntityType], - [Flows][google.cloud.dialogflow.cx.v3.Flow], - [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment], - [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], - [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - and so on to manage the conversation flows. - - """ - # 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([agent, 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 = gcdc_agent.UpdateAgentRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if agent is not None: - request.agent = agent - 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_agent, - 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(( - ("agent.name", request.agent.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_agent(self, - request: Optional[Union[agent.DeleteAgentRequest, 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 the specified agent. - - .. 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 dialogflowcx_v3 - - async def sample_delete_agent(): - # Create a client - client = dialogflowcx_v3.AgentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteAgentRequest( - name="name_value", - ) - - # Make the request - await client.delete_agent(request=request) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.DeleteAgentRequest, dict]]): - The request object. The request message for - [Agents.DeleteAgent][google.cloud.dialogflow.cx.v3.Agents.DeleteAgent]. - name (:class:`str`): - Required. The name of the agent to delete. Format: - ``projects//locations//agents/``. - - 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 = agent.DeleteAgentRequest(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_agent, - 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 export_agent(self, - request: Optional[Union[agent.ExportAgentRequest, 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"""Exports the specified agent to a binary file. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: - [ExportAgentResponse][google.cloud.dialogflow.cx.v3.ExportAgentResponse] - - .. 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 dialogflowcx_v3 - - async def sample_export_agent(): - # Create a client - client = dialogflowcx_v3.AgentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ExportAgentRequest( - name="name_value", - ) - - # Make the request - operation = client.export_agent(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ExportAgentRequest, dict]]): - The request object. The request message for - [Agents.ExportAgent][google.cloud.dialogflow.cx.v3.Agents.ExportAgent]. - 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.dialogflowcx_v3.types.ExportAgentResponse` The response message for - [Agents.ExportAgent][google.cloud.dialogflow.cx.v3.Agents.ExportAgent]. - - """ - # Create or coerce a protobuf request object. - request = agent.ExportAgentRequest(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.export_agent, - 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, - agent.ExportAgentResponse, - metadata_type=struct_pb2.Struct, - ) - - # Done; return the response. - return response - - async def restore_agent(self, - request: Optional[Union[agent.RestoreAgentRequest, 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"""Restores the specified agent from a binary file. - - Replaces the current agent with a new one. Note that all - existing resources in agent (e.g. intents, entity types, flows) - will be removed. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: An `Empty - message `__ - - Note: You should always train flows prior to sending them - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - async def sample_restore_agent(): - # Create a client - client = dialogflowcx_v3.AgentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.RestoreAgentRequest( - agent_uri="agent_uri_value", - name="name_value", - ) - - # Make the request - operation = client.restore_agent(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.RestoreAgentRequest, dict]]): - The request object. The request message for - [Agents.RestoreAgent][google.cloud.dialogflow.cx.v3.Agents.RestoreAgent]. - 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. - request = agent.RestoreAgentRequest(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.restore_agent, - 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=struct_pb2.Struct, - ) - - # Done; return the response. - return response - - async def validate_agent(self, - request: Optional[Union[agent.ValidateAgentRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> agent.AgentValidationResult: - r"""Validates the specified agent and creates or updates - validation results. The agent in draft version is - validated. Please call this API after the training is - completed to get the complete validation results. - - .. 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 dialogflowcx_v3 - - async def sample_validate_agent(): - # Create a client - client = dialogflowcx_v3.AgentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ValidateAgentRequest( - name="name_value", - ) - - # Make the request - response = await client.validate_agent(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ValidateAgentRequest, dict]]): - The request object. The request message for - [Agents.ValidateAgent][google.cloud.dialogflow.cx.v3.Agents.ValidateAgent]. - 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.dialogflowcx_v3.types.AgentValidationResult: - The response message for - [Agents.GetAgentValidationResult][google.cloud.dialogflow.cx.v3.Agents.GetAgentValidationResult]. - - """ - # Create or coerce a protobuf request object. - request = agent.ValidateAgentRequest(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.validate_agent, - 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_agent_validation_result(self, - request: Optional[Union[agent.GetAgentValidationResultRequest, 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]] = (), - ) -> agent.AgentValidationResult: - r"""Gets the latest agent validation result. Agent - validation is performed when ValidateAgent is called. - - .. 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 dialogflowcx_v3 - - async def sample_get_agent_validation_result(): - # Create a client - client = dialogflowcx_v3.AgentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetAgentValidationResultRequest( - name="name_value", - ) - - # Make the request - response = await client.get_agent_validation_result(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.GetAgentValidationResultRequest, dict]]): - The request object. The request message for - [Agents.GetAgentValidationResult][google.cloud.dialogflow.cx.v3.Agents.GetAgentValidationResult]. - name (:class:`str`): - Required. The agent name. Format: - ``projects//locations//agents//validationResult``. - - 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.dialogflowcx_v3.types.AgentValidationResult: - The response message for - [Agents.GetAgentValidationResult][google.cloud.dialogflow.cx.v3.Agents.GetAgentValidationResult]. - - """ - # 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 = agent.GetAgentValidationResultRequest(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_agent_validation_result, - 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_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 get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**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_location, - 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_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**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_locations, - 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 __aenter__(self) -> "AgentsAsyncClient": - 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__ = ( - "AgentsAsyncClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/client.py deleted file mode 100644 index 099e952b..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/client.py +++ /dev/null @@ -1,1715 +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.dialogflowcx_v3 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.dialogflowcx_v3.services.agents import pagers -from google.cloud.dialogflowcx_v3.types import advanced_settings -from google.cloud.dialogflowcx_v3.types import agent -from google.cloud.dialogflowcx_v3.types import agent as gcdc_agent -from google.cloud.dialogflowcx_v3.types import audio_config -from google.cloud.dialogflowcx_v3.types import flow -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import struct_pb2 # type: ignore -from .transports.base import AgentsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import AgentsGrpcTransport -from .transports.grpc_asyncio import AgentsGrpcAsyncIOTransport -from .transports.rest import AgentsRestTransport - - -class AgentsClientMeta(type): - """Metaclass for the Agents 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[AgentsTransport]] - _transport_registry["grpc"] = AgentsGrpcTransport - _transport_registry["grpc_asyncio"] = AgentsGrpcAsyncIOTransport - _transport_registry["rest"] = AgentsRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[AgentsTransport]: - """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 AgentsClient(metaclass=AgentsClientMeta): - """Service for managing [Agents][google.cloud.dialogflow.cx.v3.Agent].""" - - @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 = "dialogflow.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: - AgentsClient: 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: - AgentsClient: 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) -> AgentsTransport: - """Returns the transport used by the client instance. - - Returns: - AgentsTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def agent_path(project: str,location: str,agent: str,) -> str: - """Returns a fully-qualified agent string.""" - return "projects/{project}/locations/{location}/agents/{agent}".format(project=project, location=location, agent=agent, ) - - @staticmethod - def parse_agent_path(path: str) -> Dict[str,str]: - """Parses a agent path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def agent_validation_result_path(project: str,location: str,agent: str,) -> str: - """Returns a fully-qualified agent_validation_result string.""" - return "projects/{project}/locations/{location}/agents/{agent}/validationResult".format(project=project, location=location, agent=agent, ) - - @staticmethod - def parse_agent_validation_result_path(path: str) -> Dict[str,str]: - """Parses a agent_validation_result path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/validationResult$", path) - return m.groupdict() if m else {} - - @staticmethod - def environment_path(project: str,location: str,agent: str,environment: str,) -> str: - """Returns a fully-qualified environment string.""" - return "projects/{project}/locations/{location}/agents/{agent}/environments/{environment}".format(project=project, location=location, agent=agent, environment=environment, ) - - @staticmethod - def parse_environment_path(path: str) -> Dict[str,str]: - """Parses a environment path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/environments/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def flow_path(project: str,location: str,agent: str,flow: str,) -> str: - """Returns a fully-qualified flow string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}".format(project=project, location=location, agent=agent, flow=flow, ) - - @staticmethod - def parse_flow_path(path: str) -> Dict[str,str]: - """Parses a flow path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def flow_validation_result_path(project: str,location: str,agent: str,flow: str,) -> str: - """Returns a fully-qualified flow_validation_result string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/validationResult".format(project=project, location=location, agent=agent, flow=flow, ) - - @staticmethod - def parse_flow_validation_result_path(path: str) -> Dict[str,str]: - """Parses a flow_validation_result path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)/validationResult$", path) - return m.groupdict() if m else {} - - @staticmethod - def security_settings_path(project: str,location: str,security_settings: str,) -> str: - """Returns a fully-qualified security_settings string.""" - return "projects/{project}/locations/{location}/securitySettings/{security_settings}".format(project=project, location=location, security_settings=security_settings, ) - - @staticmethod - def parse_security_settings_path(path: str) -> Dict[str,str]: - """Parses a security_settings path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/securitySettings/(?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, AgentsTransport]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the agents 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, AgentsTransport]): 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, AgentsTransport): - # transport is a AgentsTransport 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 list_agents(self, - request: Optional[Union[agent.ListAgentsRequest, 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.ListAgentsPager: - r"""Returns the list of all agents in the specified - location. - - .. 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 dialogflowcx_v3 - - def sample_list_agents(): - # Create a client - client = dialogflowcx_v3.AgentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListAgentsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_agents(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ListAgentsRequest, dict]): - The request object. The request message for - [Agents.ListAgents][google.cloud.dialogflow.cx.v3.Agents.ListAgents]. - parent (str): - Required. The location to list all agents for. Format: - ``projects//locations/``. - - 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.dialogflowcx_v3.services.agents.pagers.ListAgentsPager: - The response message for - [Agents.ListAgents][google.cloud.dialogflow.cx.v3.Agents.ListAgents]. - - 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 agent.ListAgentsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, agent.ListAgentsRequest): - request = agent.ListAgentsRequest(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_agents] - - # 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.ListAgentsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_agent(self, - request: Optional[Union[agent.GetAgentRequest, 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]] = (), - ) -> agent.Agent: - r"""Retrieves the specified agent. - - .. 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 dialogflowcx_v3 - - def sample_get_agent(): - # Create a client - client = dialogflowcx_v3.AgentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetAgentRequest( - name="name_value", - ) - - # Make the request - response = client.get_agent(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.GetAgentRequest, dict]): - The request object. The request message for - [Agents.GetAgent][google.cloud.dialogflow.cx.v3.Agents.GetAgent]. - name (str): - Required. The name of the agent. Format: - ``projects//locations//agents/``. - - 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.dialogflowcx_v3.types.Agent: - Agents are best described as Natural Language Understanding (NLU) modules - that transform user requests into actionable data. - You can include agents in your app, product, or - service to determine user intent and respond to the - user in a natural way. - - After you create an agent, you can add - [Intents][google.cloud.dialogflow.cx.v3.Intent], - [Entity - Types][google.cloud.dialogflow.cx.v3.EntityType], - [Flows][google.cloud.dialogflow.cx.v3.Flow], - [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment], - [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], - [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - and so on to manage the conversation flows. - - """ - # 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 agent.GetAgentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, agent.GetAgentRequest): - request = agent.GetAgentRequest(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_agent] - - # 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 create_agent(self, - request: Optional[Union[gcdc_agent.CreateAgentRequest, dict]] = None, - *, - parent: Optional[str] = None, - agent: Optional[gcdc_agent.Agent] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_agent.Agent: - r"""Creates an agent in the specified location. - - Note: You should always train flows prior to sending them - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - def sample_create_agent(): - # Create a client - client = dialogflowcx_v3.AgentsClient() - - # Initialize request argument(s) - agent = dialogflowcx_v3.Agent() - agent.display_name = "display_name_value" - agent.default_language_code = "default_language_code_value" - agent.time_zone = "time_zone_value" - - request = dialogflowcx_v3.CreateAgentRequest( - parent="parent_value", - agent=agent, - ) - - # Make the request - response = client.create_agent(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.CreateAgentRequest, dict]): - The request object. The request message for - [Agents.CreateAgent][google.cloud.dialogflow.cx.v3.Agents.CreateAgent]. - parent (str): - Required. The location to create a agent for. Format: - ``projects//locations/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - agent (google.cloud.dialogflowcx_v3.types.Agent): - Required. The agent to create. - This corresponds to the ``agent`` 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.dialogflowcx_v3.types.Agent: - Agents are best described as Natural Language Understanding (NLU) modules - that transform user requests into actionable data. - You can include agents in your app, product, or - service to determine user intent and respond to the - user in a natural way. - - After you create an agent, you can add - [Intents][google.cloud.dialogflow.cx.v3.Intent], - [Entity - Types][google.cloud.dialogflow.cx.v3.EntityType], - [Flows][google.cloud.dialogflow.cx.v3.Flow], - [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment], - [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], - [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - and so on to manage the conversation flows. - - """ - # 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, agent]) - 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 gcdc_agent.CreateAgentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_agent.CreateAgentRequest): - request = gcdc_agent.CreateAgentRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if agent is not None: - request.agent = agent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_agent] - - # 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_agent(self, - request: Optional[Union[gcdc_agent.UpdateAgentRequest, dict]] = None, - *, - agent: Optional[gcdc_agent.Agent] = 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]] = (), - ) -> gcdc_agent.Agent: - r"""Updates the specified agent. - - Note: You should always train flows prior to sending them - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - def sample_update_agent(): - # Create a client - client = dialogflowcx_v3.AgentsClient() - - # Initialize request argument(s) - agent = dialogflowcx_v3.Agent() - agent.display_name = "display_name_value" - agent.default_language_code = "default_language_code_value" - agent.time_zone = "time_zone_value" - - request = dialogflowcx_v3.UpdateAgentRequest( - agent=agent, - ) - - # Make the request - response = client.update_agent(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.UpdateAgentRequest, dict]): - The request object. The request message for - [Agents.UpdateAgent][google.cloud.dialogflow.cx.v3.Agents.UpdateAgent]. - agent (google.cloud.dialogflowcx_v3.types.Agent): - Required. The agent to update. - This corresponds to the ``agent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The mask to control which fields get - updated. If the mask is not present, all - fields will 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.dialogflowcx_v3.types.Agent: - Agents are best described as Natural Language Understanding (NLU) modules - that transform user requests into actionable data. - You can include agents in your app, product, or - service to determine user intent and respond to the - user in a natural way. - - After you create an agent, you can add - [Intents][google.cloud.dialogflow.cx.v3.Intent], - [Entity - Types][google.cloud.dialogflow.cx.v3.EntityType], - [Flows][google.cloud.dialogflow.cx.v3.Flow], - [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment], - [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], - [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - and so on to manage the conversation flows. - - """ - # 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([agent, 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 gcdc_agent.UpdateAgentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_agent.UpdateAgentRequest): - request = gcdc_agent.UpdateAgentRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if agent is not None: - request.agent = agent - 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_agent] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("agent.name", request.agent.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_agent(self, - request: Optional[Union[agent.DeleteAgentRequest, 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 the specified agent. - - .. 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 dialogflowcx_v3 - - def sample_delete_agent(): - # Create a client - client = dialogflowcx_v3.AgentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteAgentRequest( - name="name_value", - ) - - # Make the request - client.delete_agent(request=request) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.DeleteAgentRequest, dict]): - The request object. The request message for - [Agents.DeleteAgent][google.cloud.dialogflow.cx.v3.Agents.DeleteAgent]. - name (str): - Required. The name of the agent to delete. Format: - ``projects//locations//agents/``. - - 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 agent.DeleteAgentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, agent.DeleteAgentRequest): - request = agent.DeleteAgentRequest(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_agent] - - # 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 export_agent(self, - request: Optional[Union[agent.ExportAgentRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Exports the specified agent to a binary file. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: - [ExportAgentResponse][google.cloud.dialogflow.cx.v3.ExportAgentResponse] - - .. 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 dialogflowcx_v3 - - def sample_export_agent(): - # Create a client - client = dialogflowcx_v3.AgentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ExportAgentRequest( - name="name_value", - ) - - # Make the request - operation = client.export_agent(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ExportAgentRequest, dict]): - The request object. The request message for - [Agents.ExportAgent][google.cloud.dialogflow.cx.v3.Agents.ExportAgent]. - 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.dialogflowcx_v3.types.ExportAgentResponse` The response message for - [Agents.ExportAgent][google.cloud.dialogflow.cx.v3.Agents.ExportAgent]. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a agent.ExportAgentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, agent.ExportAgentRequest): - request = agent.ExportAgentRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.export_agent] - - # 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, - agent.ExportAgentResponse, - metadata_type=struct_pb2.Struct, - ) - - # Done; return the response. - return response - - def restore_agent(self, - request: Optional[Union[agent.RestoreAgentRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Restores the specified agent from a binary file. - - Replaces the current agent with a new one. Note that all - existing resources in agent (e.g. intents, entity types, flows) - will be removed. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: An `Empty - message `__ - - Note: You should always train flows prior to sending them - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - def sample_restore_agent(): - # Create a client - client = dialogflowcx_v3.AgentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.RestoreAgentRequest( - agent_uri="agent_uri_value", - name="name_value", - ) - - # Make the request - operation = client.restore_agent(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.RestoreAgentRequest, dict]): - The request object. The request message for - [Agents.RestoreAgent][google.cloud.dialogflow.cx.v3.Agents.RestoreAgent]. - 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. - # Minor optimization to avoid making a copy if the user passes - # in a agent.RestoreAgentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, agent.RestoreAgentRequest): - request = agent.RestoreAgentRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.restore_agent] - - # 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=struct_pb2.Struct, - ) - - # Done; return the response. - return response - - def validate_agent(self, - request: Optional[Union[agent.ValidateAgentRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> agent.AgentValidationResult: - r"""Validates the specified agent and creates or updates - validation results. The agent in draft version is - validated. Please call this API after the training is - completed to get the complete validation results. - - .. 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 dialogflowcx_v3 - - def sample_validate_agent(): - # Create a client - client = dialogflowcx_v3.AgentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ValidateAgentRequest( - name="name_value", - ) - - # Make the request - response = client.validate_agent(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ValidateAgentRequest, dict]): - The request object. The request message for - [Agents.ValidateAgent][google.cloud.dialogflow.cx.v3.Agents.ValidateAgent]. - 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.dialogflowcx_v3.types.AgentValidationResult: - The response message for - [Agents.GetAgentValidationResult][google.cloud.dialogflow.cx.v3.Agents.GetAgentValidationResult]. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a agent.ValidateAgentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, agent.ValidateAgentRequest): - request = agent.ValidateAgentRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.validate_agent] - - # 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_agent_validation_result(self, - request: Optional[Union[agent.GetAgentValidationResultRequest, 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]] = (), - ) -> agent.AgentValidationResult: - r"""Gets the latest agent validation result. Agent - validation is performed when ValidateAgent is called. - - .. 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 dialogflowcx_v3 - - def sample_get_agent_validation_result(): - # Create a client - client = dialogflowcx_v3.AgentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetAgentValidationResultRequest( - name="name_value", - ) - - # Make the request - response = client.get_agent_validation_result(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.GetAgentValidationResultRequest, dict]): - The request object. The request message for - [Agents.GetAgentValidationResult][google.cloud.dialogflow.cx.v3.Agents.GetAgentValidationResult]. - name (str): - Required. The agent name. Format: - ``projects//locations//agents//validationResult``. - - 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.dialogflowcx_v3.types.AgentValidationResult: - The response message for - [Agents.GetAgentValidationResult][google.cloud.dialogflow.cx.v3.Agents.GetAgentValidationResult]. - - """ - # 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 agent.GetAgentValidationResultRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, agent.GetAgentValidationResultRequest): - request = agent.GetAgentValidationResultRequest(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_agent_validation_result] - - # 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 __enter__(self) -> "AgentsClient": - 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,) - - def get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.get_location, - 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 list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.list_locations, - 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 - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "AgentsClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/pagers.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/pagers.py deleted file mode 100644 index da389019..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/pagers.py +++ /dev/null @@ -1,139 +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.dialogflowcx_v3.types import agent - - -class ListAgentsPager: - """A pager for iterating through ``list_agents`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListAgentsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``agents`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListAgents`` requests and continue to iterate - through the ``agents`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListAgentsResponse` - 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[..., agent.ListAgentsResponse], - request: agent.ListAgentsRequest, - response: agent.ListAgentsResponse, - *, - 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.dialogflowcx_v3.types.ListAgentsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListAgentsResponse): - 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 = agent.ListAgentsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[agent.ListAgentsResponse]: - 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[agent.Agent]: - for page in self.pages: - yield from page.agents - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListAgentsAsyncPager: - """A pager for iterating through ``list_agents`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListAgentsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``agents`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListAgents`` requests and continue to iterate - through the ``agents`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListAgentsResponse` - 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[agent.ListAgentsResponse]], - request: agent.ListAgentsRequest, - response: agent.ListAgentsResponse, - *, - 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.dialogflowcx_v3.types.ListAgentsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListAgentsResponse): - 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 = agent.ListAgentsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[agent.ListAgentsResponse]: - 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[agent.Agent]: - async def async_generator(): - async for page in self.pages: - for response in page.agents: - 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/v3/google/cloud/dialogflowcx_v3/services/agents/transports/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/transports/__init__.py deleted file mode 100644 index 37f7aa34..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/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 AgentsTransport -from .grpc import AgentsGrpcTransport -from .grpc_asyncio import AgentsGrpcAsyncIOTransport -from .rest import AgentsRestTransport -from .rest import AgentsRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[AgentsTransport]] -_transport_registry['grpc'] = AgentsGrpcTransport -_transport_registry['grpc_asyncio'] = AgentsGrpcAsyncIOTransport -_transport_registry['rest'] = AgentsRestTransport - -__all__ = ( - 'AgentsTransport', - 'AgentsGrpcTransport', - 'AgentsGrpcAsyncIOTransport', - 'AgentsRestTransport', - 'AgentsRestInterceptor', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/transports/base.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/transports/base.py deleted file mode 100644 index bc941260..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/transports/base.py +++ /dev/null @@ -1,321 +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.dialogflowcx_v3 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.dialogflowcx_v3.types import agent -from google.cloud.dialogflowcx_v3.types import agent as gcdc_agent -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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 AgentsTransport(abc.ABC): - """Abstract transport class for Agents.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/dialogflow', - ) - - DEFAULT_HOST: str = 'dialogflow.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.list_agents: gapic_v1.method.wrap_method( - self.list_agents, - default_timeout=None, - client_info=client_info, - ), - self.get_agent: gapic_v1.method.wrap_method( - self.get_agent, - default_timeout=None, - client_info=client_info, - ), - self.create_agent: gapic_v1.method.wrap_method( - self.create_agent, - default_retry=retries.Retry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=180.0, - ), - default_timeout=180.0, - client_info=client_info, - ), - self.update_agent: gapic_v1.method.wrap_method( - self.update_agent, - default_timeout=None, - client_info=client_info, - ), - self.delete_agent: gapic_v1.method.wrap_method( - self.delete_agent, - default_timeout=None, - client_info=client_info, - ), - self.export_agent: gapic_v1.method.wrap_method( - self.export_agent, - default_timeout=None, - client_info=client_info, - ), - self.restore_agent: gapic_v1.method.wrap_method( - self.restore_agent, - default_timeout=None, - client_info=client_info, - ), - self.validate_agent: gapic_v1.method.wrap_method( - self.validate_agent, - default_timeout=None, - client_info=client_info, - ), - self.get_agent_validation_result: gapic_v1.method.wrap_method( - self.get_agent_validation_result, - 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 list_agents(self) -> Callable[ - [agent.ListAgentsRequest], - Union[ - agent.ListAgentsResponse, - Awaitable[agent.ListAgentsResponse] - ]]: - raise NotImplementedError() - - @property - def get_agent(self) -> Callable[ - [agent.GetAgentRequest], - Union[ - agent.Agent, - Awaitable[agent.Agent] - ]]: - raise NotImplementedError() - - @property - def create_agent(self) -> Callable[ - [gcdc_agent.CreateAgentRequest], - Union[ - gcdc_agent.Agent, - Awaitable[gcdc_agent.Agent] - ]]: - raise NotImplementedError() - - @property - def update_agent(self) -> Callable[ - [gcdc_agent.UpdateAgentRequest], - Union[ - gcdc_agent.Agent, - Awaitable[gcdc_agent.Agent] - ]]: - raise NotImplementedError() - - @property - def delete_agent(self) -> Callable[ - [agent.DeleteAgentRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def export_agent(self) -> Callable[ - [agent.ExportAgentRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def restore_agent(self) -> Callable[ - [agent.RestoreAgentRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def validate_agent(self) -> Callable[ - [agent.ValidateAgentRequest], - Union[ - agent.AgentValidationResult, - Awaitable[agent.AgentValidationResult] - ]]: - raise NotImplementedError() - - @property - def get_agent_validation_result(self) -> Callable[ - [agent.GetAgentValidationResultRequest], - Union[ - agent.AgentValidationResult, - Awaitable[agent.AgentValidationResult] - ]]: - 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 get_location(self, - ) -> Callable[ - [locations_pb2.GetLocationRequest], - Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], - ]: - raise NotImplementedError() - - @property - def list_locations(self, - ) -> Callable[ - [locations_pb2.ListLocationsRequest], - Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'AgentsTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/transports/grpc.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/transports/grpc.py deleted file mode 100644 index 3268244f..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/transports/grpc.py +++ /dev/null @@ -1,626 +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.dialogflowcx_v3.types import agent -from google.cloud.dialogflowcx_v3.types import agent as gcdc_agent -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import AgentsTransport, DEFAULT_CLIENT_INFO - - -class AgentsGrpcTransport(AgentsTransport): - """gRPC backend transport for Agents. - - Service for managing [Agents][google.cloud.dialogflow.cx.v3.Agent]. - - 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 = 'dialogflow.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 = 'dialogflow.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 list_agents(self) -> Callable[ - [agent.ListAgentsRequest], - agent.ListAgentsResponse]: - r"""Return a callable for the list agents method over gRPC. - - Returns the list of all agents in the specified - location. - - Returns: - Callable[[~.ListAgentsRequest], - ~.ListAgentsResponse]: - 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_agents' not in self._stubs: - self._stubs['list_agents'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Agents/ListAgents', - request_serializer=agent.ListAgentsRequest.serialize, - response_deserializer=agent.ListAgentsResponse.deserialize, - ) - return self._stubs['list_agents'] - - @property - def get_agent(self) -> Callable[ - [agent.GetAgentRequest], - agent.Agent]: - r"""Return a callable for the get agent method over gRPC. - - Retrieves the specified agent. - - Returns: - Callable[[~.GetAgentRequest], - ~.Agent]: - 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_agent' not in self._stubs: - self._stubs['get_agent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Agents/GetAgent', - request_serializer=agent.GetAgentRequest.serialize, - response_deserializer=agent.Agent.deserialize, - ) - return self._stubs['get_agent'] - - @property - def create_agent(self) -> Callable[ - [gcdc_agent.CreateAgentRequest], - gcdc_agent.Agent]: - r"""Return a callable for the create agent method over gRPC. - - Creates an agent in the specified location. - - Note: You should always train flows prior to sending them - queries. See the `training - documentation `__. - - Returns: - Callable[[~.CreateAgentRequest], - ~.Agent]: - 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_agent' not in self._stubs: - self._stubs['create_agent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Agents/CreateAgent', - request_serializer=gcdc_agent.CreateAgentRequest.serialize, - response_deserializer=gcdc_agent.Agent.deserialize, - ) - return self._stubs['create_agent'] - - @property - def update_agent(self) -> Callable[ - [gcdc_agent.UpdateAgentRequest], - gcdc_agent.Agent]: - r"""Return a callable for the update agent method over gRPC. - - Updates the specified agent. - - Note: You should always train flows prior to sending them - queries. See the `training - documentation `__. - - Returns: - Callable[[~.UpdateAgentRequest], - ~.Agent]: - 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_agent' not in self._stubs: - self._stubs['update_agent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Agents/UpdateAgent', - request_serializer=gcdc_agent.UpdateAgentRequest.serialize, - response_deserializer=gcdc_agent.Agent.deserialize, - ) - return self._stubs['update_agent'] - - @property - def delete_agent(self) -> Callable[ - [agent.DeleteAgentRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete agent method over gRPC. - - Deletes the specified agent. - - Returns: - Callable[[~.DeleteAgentRequest], - ~.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_agent' not in self._stubs: - self._stubs['delete_agent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Agents/DeleteAgent', - request_serializer=agent.DeleteAgentRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_agent'] - - @property - def export_agent(self) -> Callable[ - [agent.ExportAgentRequest], - operations_pb2.Operation]: - r"""Return a callable for the export agent method over gRPC. - - Exports the specified agent to a binary file. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: - [ExportAgentResponse][google.cloud.dialogflow.cx.v3.ExportAgentResponse] - - Returns: - Callable[[~.ExportAgentRequest], - ~.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_agent' not in self._stubs: - self._stubs['export_agent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Agents/ExportAgent', - request_serializer=agent.ExportAgentRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['export_agent'] - - @property - def restore_agent(self) -> Callable[ - [agent.RestoreAgentRequest], - operations_pb2.Operation]: - r"""Return a callable for the restore agent method over gRPC. - - Restores the specified agent from a binary file. - - Replaces the current agent with a new one. Note that all - existing resources in agent (e.g. intents, entity types, flows) - will be removed. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: An `Empty - message `__ - - Note: You should always train flows prior to sending them - queries. See the `training - documentation `__. - - Returns: - Callable[[~.RestoreAgentRequest], - ~.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 'restore_agent' not in self._stubs: - self._stubs['restore_agent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Agents/RestoreAgent', - request_serializer=agent.RestoreAgentRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['restore_agent'] - - @property - def validate_agent(self) -> Callable[ - [agent.ValidateAgentRequest], - agent.AgentValidationResult]: - r"""Return a callable for the validate agent method over gRPC. - - Validates the specified agent and creates or updates - validation results. The agent in draft version is - validated. Please call this API after the training is - completed to get the complete validation results. - - Returns: - Callable[[~.ValidateAgentRequest], - ~.AgentValidationResult]: - 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 'validate_agent' not in self._stubs: - self._stubs['validate_agent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Agents/ValidateAgent', - request_serializer=agent.ValidateAgentRequest.serialize, - response_deserializer=agent.AgentValidationResult.deserialize, - ) - return self._stubs['validate_agent'] - - @property - def get_agent_validation_result(self) -> Callable[ - [agent.GetAgentValidationResultRequest], - agent.AgentValidationResult]: - r"""Return a callable for the get agent validation result method over gRPC. - - Gets the latest agent validation result. Agent - validation is performed when ValidateAgent is called. - - Returns: - Callable[[~.GetAgentValidationResultRequest], - ~.AgentValidationResult]: - 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_agent_validation_result' not in self._stubs: - self._stubs['get_agent_validation_result'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Agents/GetAgentValidationResult', - request_serializer=agent.GetAgentValidationResultRequest.serialize, - response_deserializer=agent.AgentValidationResult.deserialize, - ) - return self._stubs['get_agent_validation_result'] - - 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 list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'AgentsGrpcTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/transports/grpc_asyncio.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/transports/grpc_asyncio.py deleted file mode 100644 index aeac8465..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/transports/grpc_asyncio.py +++ /dev/null @@ -1,625 +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.dialogflowcx_v3.types import agent -from google.cloud.dialogflowcx_v3.types import agent as gcdc_agent -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import AgentsTransport, DEFAULT_CLIENT_INFO -from .grpc import AgentsGrpcTransport - - -class AgentsGrpcAsyncIOTransport(AgentsTransport): - """gRPC AsyncIO backend transport for Agents. - - Service for managing [Agents][google.cloud.dialogflow.cx.v3.Agent]. - - 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 = 'dialogflow.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 = 'dialogflow.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 list_agents(self) -> Callable[ - [agent.ListAgentsRequest], - Awaitable[agent.ListAgentsResponse]]: - r"""Return a callable for the list agents method over gRPC. - - Returns the list of all agents in the specified - location. - - Returns: - Callable[[~.ListAgentsRequest], - Awaitable[~.ListAgentsResponse]]: - 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_agents' not in self._stubs: - self._stubs['list_agents'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Agents/ListAgents', - request_serializer=agent.ListAgentsRequest.serialize, - response_deserializer=agent.ListAgentsResponse.deserialize, - ) - return self._stubs['list_agents'] - - @property - def get_agent(self) -> Callable[ - [agent.GetAgentRequest], - Awaitable[agent.Agent]]: - r"""Return a callable for the get agent method over gRPC. - - Retrieves the specified agent. - - Returns: - Callable[[~.GetAgentRequest], - Awaitable[~.Agent]]: - 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_agent' not in self._stubs: - self._stubs['get_agent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Agents/GetAgent', - request_serializer=agent.GetAgentRequest.serialize, - response_deserializer=agent.Agent.deserialize, - ) - return self._stubs['get_agent'] - - @property - def create_agent(self) -> Callable[ - [gcdc_agent.CreateAgentRequest], - Awaitable[gcdc_agent.Agent]]: - r"""Return a callable for the create agent method over gRPC. - - Creates an agent in the specified location. - - Note: You should always train flows prior to sending them - queries. See the `training - documentation `__. - - Returns: - Callable[[~.CreateAgentRequest], - Awaitable[~.Agent]]: - 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_agent' not in self._stubs: - self._stubs['create_agent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Agents/CreateAgent', - request_serializer=gcdc_agent.CreateAgentRequest.serialize, - response_deserializer=gcdc_agent.Agent.deserialize, - ) - return self._stubs['create_agent'] - - @property - def update_agent(self) -> Callable[ - [gcdc_agent.UpdateAgentRequest], - Awaitable[gcdc_agent.Agent]]: - r"""Return a callable for the update agent method over gRPC. - - Updates the specified agent. - - Note: You should always train flows prior to sending them - queries. See the `training - documentation `__. - - Returns: - Callable[[~.UpdateAgentRequest], - Awaitable[~.Agent]]: - 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_agent' not in self._stubs: - self._stubs['update_agent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Agents/UpdateAgent', - request_serializer=gcdc_agent.UpdateAgentRequest.serialize, - response_deserializer=gcdc_agent.Agent.deserialize, - ) - return self._stubs['update_agent'] - - @property - def delete_agent(self) -> Callable[ - [agent.DeleteAgentRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete agent method over gRPC. - - Deletes the specified agent. - - Returns: - Callable[[~.DeleteAgentRequest], - 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_agent' not in self._stubs: - self._stubs['delete_agent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Agents/DeleteAgent', - request_serializer=agent.DeleteAgentRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_agent'] - - @property - def export_agent(self) -> Callable[ - [agent.ExportAgentRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the export agent method over gRPC. - - Exports the specified agent to a binary file. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: - [ExportAgentResponse][google.cloud.dialogflow.cx.v3.ExportAgentResponse] - - Returns: - Callable[[~.ExportAgentRequest], - 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_agent' not in self._stubs: - self._stubs['export_agent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Agents/ExportAgent', - request_serializer=agent.ExportAgentRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['export_agent'] - - @property - def restore_agent(self) -> Callable[ - [agent.RestoreAgentRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the restore agent method over gRPC. - - Restores the specified agent from a binary file. - - Replaces the current agent with a new one. Note that all - existing resources in agent (e.g. intents, entity types, flows) - will be removed. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: An `Empty - message `__ - - Note: You should always train flows prior to sending them - queries. See the `training - documentation `__. - - Returns: - Callable[[~.RestoreAgentRequest], - 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 'restore_agent' not in self._stubs: - self._stubs['restore_agent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Agents/RestoreAgent', - request_serializer=agent.RestoreAgentRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['restore_agent'] - - @property - def validate_agent(self) -> Callable[ - [agent.ValidateAgentRequest], - Awaitable[agent.AgentValidationResult]]: - r"""Return a callable for the validate agent method over gRPC. - - Validates the specified agent and creates or updates - validation results. The agent in draft version is - validated. Please call this API after the training is - completed to get the complete validation results. - - Returns: - Callable[[~.ValidateAgentRequest], - Awaitable[~.AgentValidationResult]]: - 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 'validate_agent' not in self._stubs: - self._stubs['validate_agent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Agents/ValidateAgent', - request_serializer=agent.ValidateAgentRequest.serialize, - response_deserializer=agent.AgentValidationResult.deserialize, - ) - return self._stubs['validate_agent'] - - @property - def get_agent_validation_result(self) -> Callable[ - [agent.GetAgentValidationResultRequest], - Awaitable[agent.AgentValidationResult]]: - r"""Return a callable for the get agent validation result method over gRPC. - - Gets the latest agent validation result. Agent - validation is performed when ValidateAgent is called. - - Returns: - Callable[[~.GetAgentValidationResultRequest], - Awaitable[~.AgentValidationResult]]: - 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_agent_validation_result' not in self._stubs: - self._stubs['get_agent_validation_result'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Agents/GetAgentValidationResult', - request_serializer=agent.GetAgentValidationResultRequest.serialize, - response_deserializer=agent.AgentValidationResult.deserialize, - ) - return self._stubs['get_agent_validation_result'] - - 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"] - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - -__all__ = ( - 'AgentsGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/transports/rest.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/transports/rest.py deleted file mode 100644 index 9317ae4c..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/agents/transports/rest.py +++ /dev/null @@ -1,1743 +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 google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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.dialogflowcx_v3.types import agent -from google.cloud.dialogflowcx_v3.types import agent as gcdc_agent -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore - -from .base import AgentsTransport, 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 AgentsRestInterceptor: - """Interceptor for Agents. - - 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 AgentsRestTransport. - - .. code-block:: python - class MyCustomAgentsInterceptor(AgentsRestInterceptor): - def pre_create_agent(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_agent(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_agent(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_export_agent(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_export_agent(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_agent(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_agent(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_agent_validation_result(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_agent_validation_result(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_agents(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_agents(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_restore_agent(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_restore_agent(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_agent(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_agent(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_validate_agent(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_validate_agent(self, response): - logging.log(f"Received response: {response}") - return response - - transport = AgentsRestTransport(interceptor=MyCustomAgentsInterceptor()) - client = AgentsClient(transport=transport) - - - """ - def pre_create_agent(self, request: gcdc_agent.CreateAgentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_agent.CreateAgentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_agent - - Override in a subclass to manipulate the request or metadata - before they are sent to the Agents server. - """ - return request, metadata - - def post_create_agent(self, response: gcdc_agent.Agent) -> gcdc_agent.Agent: - """Post-rpc interceptor for create_agent - - Override in a subclass to manipulate the response - after it is returned by the Agents server but before - it is returned to user code. - """ - return response - def pre_delete_agent(self, request: agent.DeleteAgentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[agent.DeleteAgentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_agent - - Override in a subclass to manipulate the request or metadata - before they are sent to the Agents server. - """ - return request, metadata - - def pre_export_agent(self, request: agent.ExportAgentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[agent.ExportAgentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for export_agent - - Override in a subclass to manipulate the request or metadata - before they are sent to the Agents server. - """ - return request, metadata - - def post_export_agent(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for export_agent - - Override in a subclass to manipulate the response - after it is returned by the Agents server but before - it is returned to user code. - """ - return response - def pre_get_agent(self, request: agent.GetAgentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[agent.GetAgentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_agent - - Override in a subclass to manipulate the request or metadata - before they are sent to the Agents server. - """ - return request, metadata - - def post_get_agent(self, response: agent.Agent) -> agent.Agent: - """Post-rpc interceptor for get_agent - - Override in a subclass to manipulate the response - after it is returned by the Agents server but before - it is returned to user code. - """ - return response - def pre_get_agent_validation_result(self, request: agent.GetAgentValidationResultRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[agent.GetAgentValidationResultRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_agent_validation_result - - Override in a subclass to manipulate the request or metadata - before they are sent to the Agents server. - """ - return request, metadata - - def post_get_agent_validation_result(self, response: agent.AgentValidationResult) -> agent.AgentValidationResult: - """Post-rpc interceptor for get_agent_validation_result - - Override in a subclass to manipulate the response - after it is returned by the Agents server but before - it is returned to user code. - """ - return response - def pre_list_agents(self, request: agent.ListAgentsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[agent.ListAgentsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_agents - - Override in a subclass to manipulate the request or metadata - before they are sent to the Agents server. - """ - return request, metadata - - def post_list_agents(self, response: agent.ListAgentsResponse) -> agent.ListAgentsResponse: - """Post-rpc interceptor for list_agents - - Override in a subclass to manipulate the response - after it is returned by the Agents server but before - it is returned to user code. - """ - return response - def pre_restore_agent(self, request: agent.RestoreAgentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[agent.RestoreAgentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for restore_agent - - Override in a subclass to manipulate the request or metadata - before they are sent to the Agents server. - """ - return request, metadata - - def post_restore_agent(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for restore_agent - - Override in a subclass to manipulate the response - after it is returned by the Agents server but before - it is returned to user code. - """ - return response - def pre_update_agent(self, request: gcdc_agent.UpdateAgentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_agent.UpdateAgentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_agent - - Override in a subclass to manipulate the request or metadata - before they are sent to the Agents server. - """ - return request, metadata - - def post_update_agent(self, response: gcdc_agent.Agent) -> gcdc_agent.Agent: - """Post-rpc interceptor for update_agent - - Override in a subclass to manipulate the response - after it is returned by the Agents server but before - it is returned to user code. - """ - return response - def pre_validate_agent(self, request: agent.ValidateAgentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[agent.ValidateAgentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for validate_agent - - Override in a subclass to manipulate the request or metadata - before they are sent to the Agents server. - """ - return request, metadata - - def post_validate_agent(self, response: agent.AgentValidationResult) -> agent.AgentValidationResult: - """Post-rpc interceptor for validate_agent - - Override in a subclass to manipulate the response - after it is returned by the Agents server but before - it is returned to user code. - """ - return response - - def pre_get_location( - self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_location - - Override in a subclass to manipulate the request or metadata - before they are sent to the Agents server. - """ - return request, metadata - - def post_get_location( - self, response: locations_pb2.Location - ) -> locations_pb2.Location: - """Post-rpc interceptor for get_location - - Override in a subclass to manipulate the response - after it is returned by the Agents server but before - it is returned to user code. - """ - return response - def pre_list_locations( - self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_locations - - Override in a subclass to manipulate the request or metadata - before they are sent to the Agents server. - """ - return request, metadata - - def post_list_locations( - self, response: locations_pb2.ListLocationsResponse - ) -> locations_pb2.ListLocationsResponse: - """Post-rpc interceptor for list_locations - - Override in a subclass to manipulate the response - after it is returned by the Agents 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 Agents 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 Agents 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 Agents 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 Agents 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 Agents 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 Agents server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class AgentsRestStub: - _session: AuthorizedSession - _host: str - _interceptor: AgentsRestInterceptor - - -class AgentsRestTransport(AgentsTransport): - """REST backend transport for Agents. - - Service for managing [Agents][google.cloud.dialogflow.cx.v3.Agent]. - - 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 = 'dialogflow.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[AgentsRestInterceptor] = 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 AgentsRestInterceptor() - 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': '/v3/{name=projects/*/operations/*}:cancel', - }, - { - 'method': 'post', - 'uri': '/v3/{name=projects/*/locations/*/operations/*}:cancel', - }, - ], - 'google.longrunning.Operations.GetOperation': [ - { - 'method': 'get', - 'uri': '/v3/{name=projects/*/operations/*}', - }, - { - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/operations/*}', - }, - ], - 'google.longrunning.Operations.ListOperations': [ - { - 'method': 'get', - 'uri': '/v3/{name=projects/*}/operations', - }, - { - 'method': 'get', - 'uri': '/v3/{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="v3") - - self._operations_client = operations_v1.AbstractOperationsClient(transport=rest_transport) - - # Return the client from cache. - return self._operations_client - - class _CreateAgent(AgentsRestStub): - def __hash__(self): - return hash("CreateAgent") - - __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: gcdc_agent.CreateAgentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_agent.Agent: - r"""Call the create agent method over HTTP. - - Args: - request (~.gcdc_agent.CreateAgentRequest): - The request object. The request message for - [Agents.CreateAgent][google.cloud.dialogflow.cx.v3.Agents.CreateAgent]. - 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: - ~.gcdc_agent.Agent: - Agents are best described as Natural Language - Understanding (NLU) modules that transform user requests - into actionable data. You can include agents in your - app, product, or service to determine user intent and - respond to the user in a natural way. - - After you create an agent, you can add - [Intents][google.cloud.dialogflow.cx.v3.Intent], [Entity - Types][google.cloud.dialogflow.cx.v3.EntityType], - [Flows][google.cloud.dialogflow.cx.v3.Flow], - [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment], - [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], - [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - and so on to manage the conversation flows. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v3/{parent=projects/*/locations/*}/agents', - 'body': 'agent', - }, - ] - request, metadata = self._interceptor.pre_create_agent(request, metadata) - pb_request = gcdc_agent.CreateAgentRequest.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 = gcdc_agent.Agent() - pb_resp = gcdc_agent.Agent.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_agent(resp) - return resp - - class _DeleteAgent(AgentsRestStub): - def __hash__(self): - return hash("DeleteAgent") - - __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: agent.DeleteAgentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete agent method over HTTP. - - Args: - request (~.agent.DeleteAgentRequest): - The request object. The request message for - [Agents.DeleteAgent][google.cloud.dialogflow.cx.v3.Agents.DeleteAgent]. - 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': '/v3/{name=projects/*/locations/*/agents/*}', - }, - ] - request, metadata = self._interceptor.pre_delete_agent(request, metadata) - pb_request = agent.DeleteAgentRequest.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 _ExportAgent(AgentsRestStub): - def __hash__(self): - return hash("ExportAgent") - - __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: agent.ExportAgentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the export agent method over HTTP. - - Args: - request (~.agent.ExportAgentRequest): - The request object. The request message for - [Agents.ExportAgent][google.cloud.dialogflow.cx.v3.Agents.ExportAgent]. - 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': '/v3/{name=projects/*/locations/*/agents/*}:export', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_export_agent(request, metadata) - pb_request = agent.ExportAgentRequest.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_agent(resp) - return resp - - class _GetAgent(AgentsRestStub): - def __hash__(self): - return hash("GetAgent") - - __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: agent.GetAgentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> agent.Agent: - r"""Call the get agent method over HTTP. - - Args: - request (~.agent.GetAgentRequest): - The request object. The request message for - [Agents.GetAgent][google.cloud.dialogflow.cx.v3.Agents.GetAgent]. - 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: - ~.agent.Agent: - Agents are best described as Natural Language - Understanding (NLU) modules that transform user requests - into actionable data. You can include agents in your - app, product, or service to determine user intent and - respond to the user in a natural way. - - After you create an agent, you can add - [Intents][google.cloud.dialogflow.cx.v3.Intent], [Entity - Types][google.cloud.dialogflow.cx.v3.EntityType], - [Flows][google.cloud.dialogflow.cx.v3.Flow], - [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment], - [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], - [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - and so on to manage the conversation flows. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/agents/*}', - }, - ] - request, metadata = self._interceptor.pre_get_agent(request, metadata) - pb_request = agent.GetAgentRequest.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 = agent.Agent() - pb_resp = agent.Agent.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_agent(resp) - return resp - - class _GetAgentValidationResult(AgentsRestStub): - def __hash__(self): - return hash("GetAgentValidationResult") - - __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: agent.GetAgentValidationResultRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> agent.AgentValidationResult: - r"""Call the get agent validation - result method over HTTP. - - Args: - request (~.agent.GetAgentValidationResultRequest): - The request object. The request message for - [Agents.GetAgentValidationResult][google.cloud.dialogflow.cx.v3.Agents.GetAgentValidationResult]. - 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: - ~.agent.AgentValidationResult: - The response message for - [Agents.GetAgentValidationResult][google.cloud.dialogflow.cx.v3.Agents.GetAgentValidationResult]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/validationResult}', - }, - ] - request, metadata = self._interceptor.pre_get_agent_validation_result(request, metadata) - pb_request = agent.GetAgentValidationResultRequest.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 = agent.AgentValidationResult() - pb_resp = agent.AgentValidationResult.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_agent_validation_result(resp) - return resp - - class _ListAgents(AgentsRestStub): - def __hash__(self): - return hash("ListAgents") - - __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: agent.ListAgentsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> agent.ListAgentsResponse: - r"""Call the list agents method over HTTP. - - Args: - request (~.agent.ListAgentsRequest): - The request object. The request message for - [Agents.ListAgents][google.cloud.dialogflow.cx.v3.Agents.ListAgents]. - 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: - ~.agent.ListAgentsResponse: - The response message for - [Agents.ListAgents][google.cloud.dialogflow.cx.v3.Agents.ListAgents]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{parent=projects/*/locations/*}/agents', - }, - ] - request, metadata = self._interceptor.pre_list_agents(request, metadata) - pb_request = agent.ListAgentsRequest.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 = agent.ListAgentsResponse() - pb_resp = agent.ListAgentsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_agents(resp) - return resp - - class _RestoreAgent(AgentsRestStub): - def __hash__(self): - return hash("RestoreAgent") - - __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: agent.RestoreAgentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the restore agent method over HTTP. - - Args: - request (~.agent.RestoreAgentRequest): - The request object. The request message for - [Agents.RestoreAgent][google.cloud.dialogflow.cx.v3.Agents.RestoreAgent]. - 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': '/v3/{name=projects/*/locations/*/agents/*}:restore', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_restore_agent(request, metadata) - pb_request = agent.RestoreAgentRequest.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_restore_agent(resp) - return resp - - class _UpdateAgent(AgentsRestStub): - def __hash__(self): - return hash("UpdateAgent") - - __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: gcdc_agent.UpdateAgentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_agent.Agent: - r"""Call the update agent method over HTTP. - - Args: - request (~.gcdc_agent.UpdateAgentRequest): - The request object. The request message for - [Agents.UpdateAgent][google.cloud.dialogflow.cx.v3.Agents.UpdateAgent]. - 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: - ~.gcdc_agent.Agent: - Agents are best described as Natural Language - Understanding (NLU) modules that transform user requests - into actionable data. You can include agents in your - app, product, or service to determine user intent and - respond to the user in a natural way. - - After you create an agent, you can add - [Intents][google.cloud.dialogflow.cx.v3.Intent], [Entity - Types][google.cloud.dialogflow.cx.v3.EntityType], - [Flows][google.cloud.dialogflow.cx.v3.Flow], - [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment], - [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], - [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - and so on to manage the conversation flows. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v3/{agent.name=projects/*/locations/*/agents/*}', - 'body': 'agent', - }, - ] - request, metadata = self._interceptor.pre_update_agent(request, metadata) - pb_request = gcdc_agent.UpdateAgentRequest.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 = gcdc_agent.Agent() - pb_resp = gcdc_agent.Agent.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_agent(resp) - return resp - - class _ValidateAgent(AgentsRestStub): - def __hash__(self): - return hash("ValidateAgent") - - __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: agent.ValidateAgentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> agent.AgentValidationResult: - r"""Call the validate agent method over HTTP. - - Args: - request (~.agent.ValidateAgentRequest): - The request object. The request message for - [Agents.ValidateAgent][google.cloud.dialogflow.cx.v3.Agents.ValidateAgent]. - 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: - ~.agent.AgentValidationResult: - The response message for - [Agents.GetAgentValidationResult][google.cloud.dialogflow.cx.v3.Agents.GetAgentValidationResult]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v3/{name=projects/*/locations/*/agents/*}:validate', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_validate_agent(request, metadata) - pb_request = agent.ValidateAgentRequest.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 = agent.AgentValidationResult() - pb_resp = agent.AgentValidationResult.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_validate_agent(resp) - return resp - - @property - def create_agent(self) -> Callable[ - [gcdc_agent.CreateAgentRequest], - gcdc_agent.Agent]: - # 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._CreateAgent(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_agent(self) -> Callable[ - [agent.DeleteAgentRequest], - 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._DeleteAgent(self._session, self._host, self._interceptor) # type: ignore - - @property - def export_agent(self) -> Callable[ - [agent.ExportAgentRequest], - 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._ExportAgent(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_agent(self) -> Callable[ - [agent.GetAgentRequest], - agent.Agent]: - # 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._GetAgent(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_agent_validation_result(self) -> Callable[ - [agent.GetAgentValidationResultRequest], - agent.AgentValidationResult]: - # 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._GetAgentValidationResult(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_agents(self) -> Callable[ - [agent.ListAgentsRequest], - agent.ListAgentsResponse]: - # 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._ListAgents(self._session, self._host, self._interceptor) # type: ignore - - @property - def restore_agent(self) -> Callable[ - [agent.RestoreAgentRequest], - 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._RestoreAgent(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_agent(self) -> Callable[ - [gcdc_agent.UpdateAgentRequest], - gcdc_agent.Agent]: - # 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._UpdateAgent(self._session, self._host, self._interceptor) # type: ignore - - @property - def validate_agent(self) -> Callable[ - [agent.ValidateAgentRequest], - agent.AgentValidationResult]: - # 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._ValidateAgent(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_location(self): - return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore - - class _GetLocation(AgentsRestStub): - def __call__(self, - request: locations_pb2.GetLocationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.Location: - - r"""Call the get location method over HTTP. - - Args: - request (locations_pb2.GetLocationRequest): - The request object for GetLocation 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: - locations_pb2.Location: Response from GetLocation method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*}', - }, - ] - - request, metadata = self._interceptor.pre_get_location(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 = locations_pb2.Location() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_get_location(resp) - return resp - - @property - def list_locations(self): - return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore - - class _ListLocations(AgentsRestStub): - def __call__(self, - request: locations_pb2.ListLocationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.ListLocationsResponse: - - r"""Call the list locations method over HTTP. - - Args: - request (locations_pb2.ListLocationsRequest): - The request object for ListLocations 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: - locations_pb2.ListLocationsResponse: Response from ListLocations method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*}/locations', - }, - ] - - request, metadata = self._interceptor.pre_list_locations(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 = locations_pb2.ListLocationsResponse() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_list_locations(resp) - return resp - - @property - def cancel_operation(self): - return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore - - class _CancelOperation(AgentsRestStub): - 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': '/v3/{name=projects/*/operations/*}:cancel', - }, -{ - 'method': 'post', - 'uri': '/v3/{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(AgentsRestStub): - 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': '/v3/{name=projects/*/operations/*}', - }, -{ - 'method': 'get', - 'uri': '/v3/{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(AgentsRestStub): - 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': '/v3/{name=projects/*}/operations', - }, -{ - 'method': 'get', - 'uri': '/v3/{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__=( - 'AgentsRestTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/__init__.py deleted file mode 100644 index 5f5759e5..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/__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 ChangelogsClient -from .async_client import ChangelogsAsyncClient - -__all__ = ( - 'ChangelogsClient', - 'ChangelogsAsyncClient', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/async_client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/async_client.py deleted file mode 100644 index c28e15c7..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/async_client.py +++ /dev/null @@ -1,672 +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.dialogflowcx_v3 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.cloud.dialogflowcx_v3.services.changelogs import pagers -from google.cloud.dialogflowcx_v3.types import changelog -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import ChangelogsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import ChangelogsGrpcAsyncIOTransport -from .client import ChangelogsClient - - -class ChangelogsAsyncClient: - """Service for managing - [Changelogs][google.cloud.dialogflow.cx.v3.Changelog]. - """ - - _client: ChangelogsClient - - DEFAULT_ENDPOINT = ChangelogsClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = ChangelogsClient.DEFAULT_MTLS_ENDPOINT - - changelog_path = staticmethod(ChangelogsClient.changelog_path) - parse_changelog_path = staticmethod(ChangelogsClient.parse_changelog_path) - common_billing_account_path = staticmethod(ChangelogsClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(ChangelogsClient.parse_common_billing_account_path) - common_folder_path = staticmethod(ChangelogsClient.common_folder_path) - parse_common_folder_path = staticmethod(ChangelogsClient.parse_common_folder_path) - common_organization_path = staticmethod(ChangelogsClient.common_organization_path) - parse_common_organization_path = staticmethod(ChangelogsClient.parse_common_organization_path) - common_project_path = staticmethod(ChangelogsClient.common_project_path) - parse_common_project_path = staticmethod(ChangelogsClient.parse_common_project_path) - common_location_path = staticmethod(ChangelogsClient.common_location_path) - parse_common_location_path = staticmethod(ChangelogsClient.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: - ChangelogsAsyncClient: The constructed client. - """ - return ChangelogsClient.from_service_account_info.__func__(ChangelogsAsyncClient, 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: - ChangelogsAsyncClient: The constructed client. - """ - return ChangelogsClient.from_service_account_file.__func__(ChangelogsAsyncClient, 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 ChangelogsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> ChangelogsTransport: - """Returns the transport used by the client instance. - - Returns: - ChangelogsTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(ChangelogsClient).get_transport_class, type(ChangelogsClient)) - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, ChangelogsTransport] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the changelogs 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, ~.ChangelogsTransport]): 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 = ChangelogsClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def list_changelogs(self, - request: Optional[Union[changelog.ListChangelogsRequest, 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.ListChangelogsAsyncPager: - r"""Returns the list of Changelogs. - - .. 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 dialogflowcx_v3 - - async def sample_list_changelogs(): - # Create a client - client = dialogflowcx_v3.ChangelogsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListChangelogsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_changelogs(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ListChangelogsRequest, dict]]): - The request object. The request message for - [Changelogs.ListChangelogs][google.cloud.dialogflow.cx.v3.Changelogs.ListChangelogs]. - parent (:class:`str`): - Required. The agent containing the changelogs. Format: - ``projects//locations//agents/``. - - 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.dialogflowcx_v3.services.changelogs.pagers.ListChangelogsAsyncPager: - The response message for - [Changelogs.ListChangelogs][google.cloud.dialogflow.cx.v3.Changelogs.ListChangelogs]. - - 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 = changelog.ListChangelogsRequest(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_changelogs, - 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.ListChangelogsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_changelog(self, - request: Optional[Union[changelog.GetChangelogRequest, 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]] = (), - ) -> changelog.Changelog: - r"""Retrieves the specified Changelog. - - .. 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 dialogflowcx_v3 - - async def sample_get_changelog(): - # Create a client - client = dialogflowcx_v3.ChangelogsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetChangelogRequest( - name="name_value", - ) - - # Make the request - response = await client.get_changelog(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.GetChangelogRequest, dict]]): - The request object. The request message for - [Changelogs.GetChangelog][google.cloud.dialogflow.cx.v3.Changelogs.GetChangelog]. - name (:class:`str`): - Required. The name of the changelog to get. Format: - ``projects//locations//agents//changelogs/``. - - 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.dialogflowcx_v3.types.Changelog: - Changelogs represents a change made - to a given agent. - - """ - # 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 = changelog.GetChangelogRequest(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_changelog, - 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_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 get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**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_location, - 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_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**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_locations, - 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 __aenter__(self) -> "ChangelogsAsyncClient": - 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__ = ( - "ChangelogsAsyncClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/client.py deleted file mode 100644 index b2e546af..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/client.py +++ /dev/null @@ -1,871 +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.dialogflowcx_v3 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.cloud.dialogflowcx_v3.services.changelogs import pagers -from google.cloud.dialogflowcx_v3.types import changelog -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import ChangelogsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import ChangelogsGrpcTransport -from .transports.grpc_asyncio import ChangelogsGrpcAsyncIOTransport -from .transports.rest import ChangelogsRestTransport - - -class ChangelogsClientMeta(type): - """Metaclass for the Changelogs 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[ChangelogsTransport]] - _transport_registry["grpc"] = ChangelogsGrpcTransport - _transport_registry["grpc_asyncio"] = ChangelogsGrpcAsyncIOTransport - _transport_registry["rest"] = ChangelogsRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[ChangelogsTransport]: - """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 ChangelogsClient(metaclass=ChangelogsClientMeta): - """Service for managing - [Changelogs][google.cloud.dialogflow.cx.v3.Changelog]. - """ - - @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 = "dialogflow.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: - ChangelogsClient: 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: - ChangelogsClient: 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) -> ChangelogsTransport: - """Returns the transport used by the client instance. - - Returns: - ChangelogsTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def changelog_path(project: str,location: str,agent: str,changelog: str,) -> str: - """Returns a fully-qualified changelog string.""" - return "projects/{project}/locations/{location}/agents/{agent}/changelogs/{changelog}".format(project=project, location=location, agent=agent, changelog=changelog, ) - - @staticmethod - def parse_changelog_path(path: str) -> Dict[str,str]: - """Parses a changelog path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/changelogs/(?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, ChangelogsTransport]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the changelogs 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, ChangelogsTransport]): 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, ChangelogsTransport): - # transport is a ChangelogsTransport 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 list_changelogs(self, - request: Optional[Union[changelog.ListChangelogsRequest, 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.ListChangelogsPager: - r"""Returns the list of Changelogs. - - .. 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 dialogflowcx_v3 - - def sample_list_changelogs(): - # Create a client - client = dialogflowcx_v3.ChangelogsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListChangelogsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_changelogs(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ListChangelogsRequest, dict]): - The request object. The request message for - [Changelogs.ListChangelogs][google.cloud.dialogflow.cx.v3.Changelogs.ListChangelogs]. - parent (str): - Required. The agent containing the changelogs. Format: - ``projects//locations//agents/``. - - 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.dialogflowcx_v3.services.changelogs.pagers.ListChangelogsPager: - The response message for - [Changelogs.ListChangelogs][google.cloud.dialogflow.cx.v3.Changelogs.ListChangelogs]. - - 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 changelog.ListChangelogsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, changelog.ListChangelogsRequest): - request = changelog.ListChangelogsRequest(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_changelogs] - - # 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.ListChangelogsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_changelog(self, - request: Optional[Union[changelog.GetChangelogRequest, 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]] = (), - ) -> changelog.Changelog: - r"""Retrieves the specified Changelog. - - .. 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 dialogflowcx_v3 - - def sample_get_changelog(): - # Create a client - client = dialogflowcx_v3.ChangelogsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetChangelogRequest( - name="name_value", - ) - - # Make the request - response = client.get_changelog(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.GetChangelogRequest, dict]): - The request object. The request message for - [Changelogs.GetChangelog][google.cloud.dialogflow.cx.v3.Changelogs.GetChangelog]. - name (str): - Required. The name of the changelog to get. Format: - ``projects//locations//agents//changelogs/``. - - 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.dialogflowcx_v3.types.Changelog: - Changelogs represents a change made - to a given agent. - - """ - # 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 changelog.GetChangelogRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, changelog.GetChangelogRequest): - request = changelog.GetChangelogRequest(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_changelog] - - # 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 __enter__(self) -> "ChangelogsClient": - 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,) - - def get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.get_location, - 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 list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.list_locations, - 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 - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "ChangelogsClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/pagers.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/pagers.py deleted file mode 100644 index 933e4094..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/pagers.py +++ /dev/null @@ -1,139 +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.dialogflowcx_v3.types import changelog - - -class ListChangelogsPager: - """A pager for iterating through ``list_changelogs`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListChangelogsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``changelogs`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListChangelogs`` requests and continue to iterate - through the ``changelogs`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListChangelogsResponse` - 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[..., changelog.ListChangelogsResponse], - request: changelog.ListChangelogsRequest, - response: changelog.ListChangelogsResponse, - *, - 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.dialogflowcx_v3.types.ListChangelogsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListChangelogsResponse): - 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 = changelog.ListChangelogsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[changelog.ListChangelogsResponse]: - 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[changelog.Changelog]: - for page in self.pages: - yield from page.changelogs - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListChangelogsAsyncPager: - """A pager for iterating through ``list_changelogs`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListChangelogsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``changelogs`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListChangelogs`` requests and continue to iterate - through the ``changelogs`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListChangelogsResponse` - 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[changelog.ListChangelogsResponse]], - request: changelog.ListChangelogsRequest, - response: changelog.ListChangelogsResponse, - *, - 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.dialogflowcx_v3.types.ListChangelogsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListChangelogsResponse): - 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 = changelog.ListChangelogsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[changelog.ListChangelogsResponse]: - 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[changelog.Changelog]: - async def async_generator(): - async for page in self.pages: - for response in page.changelogs: - 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/v3/google/cloud/dialogflowcx_v3/services/changelogs/transports/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/transports/__init__.py deleted file mode 100644 index aa909989..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/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 ChangelogsTransport -from .grpc import ChangelogsGrpcTransport -from .grpc_asyncio import ChangelogsGrpcAsyncIOTransport -from .rest import ChangelogsRestTransport -from .rest import ChangelogsRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[ChangelogsTransport]] -_transport_registry['grpc'] = ChangelogsGrpcTransport -_transport_registry['grpc_asyncio'] = ChangelogsGrpcAsyncIOTransport -_transport_registry['rest'] = ChangelogsRestTransport - -__all__ = ( - 'ChangelogsTransport', - 'ChangelogsGrpcTransport', - 'ChangelogsGrpcAsyncIOTransport', - 'ChangelogsRestTransport', - 'ChangelogsRestInterceptor', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/transports/base.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/transports/base.py deleted file mode 100644 index 37650513..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/transports/base.py +++ /dev/null @@ -1,208 +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.dialogflowcx_v3 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.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.dialogflowcx_v3.types import changelog -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -class ChangelogsTransport(abc.ABC): - """Abstract transport class for Changelogs.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/dialogflow', - ) - - DEFAULT_HOST: str = 'dialogflow.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.list_changelogs: gapic_v1.method.wrap_method( - self.list_changelogs, - default_timeout=None, - client_info=client_info, - ), - self.get_changelog: gapic_v1.method.wrap_method( - self.get_changelog, - 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 list_changelogs(self) -> Callable[ - [changelog.ListChangelogsRequest], - Union[ - changelog.ListChangelogsResponse, - Awaitable[changelog.ListChangelogsResponse] - ]]: - raise NotImplementedError() - - @property - def get_changelog(self) -> Callable[ - [changelog.GetChangelogRequest], - Union[ - changelog.Changelog, - Awaitable[changelog.Changelog] - ]]: - 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 get_location(self, - ) -> Callable[ - [locations_pb2.GetLocationRequest], - Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], - ]: - raise NotImplementedError() - - @property - def list_locations(self, - ) -> Callable[ - [locations_pb2.ListLocationsRequest], - Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'ChangelogsTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/transports/grpc.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/transports/grpc.py deleted file mode 100644 index 0891bddc..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/transports/grpc.py +++ /dev/null @@ -1,383 +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 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.dialogflowcx_v3.types import changelog -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from .base import ChangelogsTransport, DEFAULT_CLIENT_INFO - - -class ChangelogsGrpcTransport(ChangelogsTransport): - """gRPC backend transport for Changelogs. - - Service for managing - [Changelogs][google.cloud.dialogflow.cx.v3.Changelog]. - - 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 = 'dialogflow.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] = {} - - 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 = 'dialogflow.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 list_changelogs(self) -> Callable[ - [changelog.ListChangelogsRequest], - changelog.ListChangelogsResponse]: - r"""Return a callable for the list changelogs method over gRPC. - - Returns the list of Changelogs. - - Returns: - Callable[[~.ListChangelogsRequest], - ~.ListChangelogsResponse]: - 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_changelogs' not in self._stubs: - self._stubs['list_changelogs'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Changelogs/ListChangelogs', - request_serializer=changelog.ListChangelogsRequest.serialize, - response_deserializer=changelog.ListChangelogsResponse.deserialize, - ) - return self._stubs['list_changelogs'] - - @property - def get_changelog(self) -> Callable[ - [changelog.GetChangelogRequest], - changelog.Changelog]: - r"""Return a callable for the get changelog method over gRPC. - - Retrieves the specified Changelog. - - Returns: - Callable[[~.GetChangelogRequest], - ~.Changelog]: - 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_changelog' not in self._stubs: - self._stubs['get_changelog'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Changelogs/GetChangelog', - request_serializer=changelog.GetChangelogRequest.serialize, - response_deserializer=changelog.Changelog.deserialize, - ) - return self._stubs['get_changelog'] - - 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 list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'ChangelogsGrpcTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/transports/grpc_asyncio.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/transports/grpc_asyncio.py deleted file mode 100644 index b9f15675..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/transports/grpc_asyncio.py +++ /dev/null @@ -1,382 +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.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.dialogflowcx_v3.types import changelog -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from .base import ChangelogsTransport, DEFAULT_CLIENT_INFO -from .grpc import ChangelogsGrpcTransport - - -class ChangelogsGrpcAsyncIOTransport(ChangelogsTransport): - """gRPC AsyncIO backend transport for Changelogs. - - Service for managing - [Changelogs][google.cloud.dialogflow.cx.v3.Changelog]. - - 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 = 'dialogflow.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 = 'dialogflow.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] = {} - - 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 list_changelogs(self) -> Callable[ - [changelog.ListChangelogsRequest], - Awaitable[changelog.ListChangelogsResponse]]: - r"""Return a callable for the list changelogs method over gRPC. - - Returns the list of Changelogs. - - Returns: - Callable[[~.ListChangelogsRequest], - Awaitable[~.ListChangelogsResponse]]: - 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_changelogs' not in self._stubs: - self._stubs['list_changelogs'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Changelogs/ListChangelogs', - request_serializer=changelog.ListChangelogsRequest.serialize, - response_deserializer=changelog.ListChangelogsResponse.deserialize, - ) - return self._stubs['list_changelogs'] - - @property - def get_changelog(self) -> Callable[ - [changelog.GetChangelogRequest], - Awaitable[changelog.Changelog]]: - r"""Return a callable for the get changelog method over gRPC. - - Retrieves the specified Changelog. - - Returns: - Callable[[~.GetChangelogRequest], - Awaitable[~.Changelog]]: - 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_changelog' not in self._stubs: - self._stubs['get_changelog'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Changelogs/GetChangelog', - request_serializer=changelog.GetChangelogRequest.serialize, - response_deserializer=changelog.Changelog.deserialize, - ) - return self._stubs['get_changelog'] - - 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"] - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - -__all__ = ( - 'ChangelogsGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/transports/rest.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/transports/rest.py deleted file mode 100644 index 48966b55..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/changelogs/transports/rest.py +++ /dev/null @@ -1,839 +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.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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.dialogflowcx_v3.types import changelog - -from .base import ChangelogsTransport, 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 ChangelogsRestInterceptor: - """Interceptor for Changelogs. - - 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 ChangelogsRestTransport. - - .. code-block:: python - class MyCustomChangelogsInterceptor(ChangelogsRestInterceptor): - def pre_get_changelog(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_changelog(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_changelogs(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_changelogs(self, response): - logging.log(f"Received response: {response}") - return response - - transport = ChangelogsRestTransport(interceptor=MyCustomChangelogsInterceptor()) - client = ChangelogsClient(transport=transport) - - - """ - def pre_get_changelog(self, request: changelog.GetChangelogRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[changelog.GetChangelogRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_changelog - - Override in a subclass to manipulate the request or metadata - before they are sent to the Changelogs server. - """ - return request, metadata - - def post_get_changelog(self, response: changelog.Changelog) -> changelog.Changelog: - """Post-rpc interceptor for get_changelog - - Override in a subclass to manipulate the response - after it is returned by the Changelogs server but before - it is returned to user code. - """ - return response - def pre_list_changelogs(self, request: changelog.ListChangelogsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[changelog.ListChangelogsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_changelogs - - Override in a subclass to manipulate the request or metadata - before they are sent to the Changelogs server. - """ - return request, metadata - - def post_list_changelogs(self, response: changelog.ListChangelogsResponse) -> changelog.ListChangelogsResponse: - """Post-rpc interceptor for list_changelogs - - Override in a subclass to manipulate the response - after it is returned by the Changelogs server but before - it is returned to user code. - """ - return response - - def pre_get_location( - self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_location - - Override in a subclass to manipulate the request or metadata - before they are sent to the Changelogs server. - """ - return request, metadata - - def post_get_location( - self, response: locations_pb2.Location - ) -> locations_pb2.Location: - """Post-rpc interceptor for get_location - - Override in a subclass to manipulate the response - after it is returned by the Changelogs server but before - it is returned to user code. - """ - return response - def pre_list_locations( - self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_locations - - Override in a subclass to manipulate the request or metadata - before they are sent to the Changelogs server. - """ - return request, metadata - - def post_list_locations( - self, response: locations_pb2.ListLocationsResponse - ) -> locations_pb2.ListLocationsResponse: - """Post-rpc interceptor for list_locations - - Override in a subclass to manipulate the response - after it is returned by the Changelogs 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 Changelogs 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 Changelogs 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 Changelogs 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 Changelogs 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 Changelogs 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 Changelogs server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class ChangelogsRestStub: - _session: AuthorizedSession - _host: str - _interceptor: ChangelogsRestInterceptor - - -class ChangelogsRestTransport(ChangelogsTransport): - """REST backend transport for Changelogs. - - Service for managing - [Changelogs][google.cloud.dialogflow.cx.v3.Changelog]. - - 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 = 'dialogflow.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[ChangelogsRestInterceptor] = 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) - if client_cert_source_for_mtls: - self._session.configure_mtls_channel(client_cert_source_for_mtls) - self._interceptor = interceptor or ChangelogsRestInterceptor() - self._prep_wrapped_messages(client_info) - - class _GetChangelog(ChangelogsRestStub): - def __hash__(self): - return hash("GetChangelog") - - __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: changelog.GetChangelogRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> changelog.Changelog: - r"""Call the get changelog method over HTTP. - - Args: - request (~.changelog.GetChangelogRequest): - The request object. The request message for - [Changelogs.GetChangelog][google.cloud.dialogflow.cx.v3.Changelogs.GetChangelog]. - 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: - ~.changelog.Changelog: - Changelogs represents a change made - to a given agent. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/changelogs/*}', - }, - ] - request, metadata = self._interceptor.pre_get_changelog(request, metadata) - pb_request = changelog.GetChangelogRequest.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 = changelog.Changelog() - pb_resp = changelog.Changelog.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_changelog(resp) - return resp - - class _ListChangelogs(ChangelogsRestStub): - def __hash__(self): - return hash("ListChangelogs") - - __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: changelog.ListChangelogsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> changelog.ListChangelogsResponse: - r"""Call the list changelogs method over HTTP. - - Args: - request (~.changelog.ListChangelogsRequest): - The request object. The request message for - [Changelogs.ListChangelogs][google.cloud.dialogflow.cx.v3.Changelogs.ListChangelogs]. - 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: - ~.changelog.ListChangelogsResponse: - The response message for - [Changelogs.ListChangelogs][google.cloud.dialogflow.cx.v3.Changelogs.ListChangelogs]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*}/changelogs', - }, - ] - request, metadata = self._interceptor.pre_list_changelogs(request, metadata) - pb_request = changelog.ListChangelogsRequest.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 = changelog.ListChangelogsResponse() - pb_resp = changelog.ListChangelogsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_changelogs(resp) - return resp - - @property - def get_changelog(self) -> Callable[ - [changelog.GetChangelogRequest], - changelog.Changelog]: - # 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._GetChangelog(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_changelogs(self) -> Callable[ - [changelog.ListChangelogsRequest], - changelog.ListChangelogsResponse]: - # 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._ListChangelogs(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_location(self): - return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore - - class _GetLocation(ChangelogsRestStub): - def __call__(self, - request: locations_pb2.GetLocationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.Location: - - r"""Call the get location method over HTTP. - - Args: - request (locations_pb2.GetLocationRequest): - The request object for GetLocation 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: - locations_pb2.Location: Response from GetLocation method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*}', - }, - ] - - request, metadata = self._interceptor.pre_get_location(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 = locations_pb2.Location() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_get_location(resp) - return resp - - @property - def list_locations(self): - return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore - - class _ListLocations(ChangelogsRestStub): - def __call__(self, - request: locations_pb2.ListLocationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.ListLocationsResponse: - - r"""Call the list locations method over HTTP. - - Args: - request (locations_pb2.ListLocationsRequest): - The request object for ListLocations 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: - locations_pb2.ListLocationsResponse: Response from ListLocations method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*}/locations', - }, - ] - - request, metadata = self._interceptor.pre_list_locations(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 = locations_pb2.ListLocationsResponse() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_list_locations(resp) - return resp - - @property - def cancel_operation(self): - return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore - - class _CancelOperation(ChangelogsRestStub): - 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': '/v3/{name=projects/*/operations/*}:cancel', - }, -{ - 'method': 'post', - 'uri': '/v3/{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(ChangelogsRestStub): - 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': '/v3/{name=projects/*/operations/*}', - }, -{ - 'method': 'get', - 'uri': '/v3/{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(ChangelogsRestStub): - 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': '/v3/{name=projects/*}/operations', - }, -{ - 'method': 'get', - 'uri': '/v3/{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__=( - 'ChangelogsRestTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/__init__.py deleted file mode 100644 index 01a89803..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/__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 DeploymentsClient -from .async_client import DeploymentsAsyncClient - -__all__ = ( - 'DeploymentsClient', - 'DeploymentsAsyncClient', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/async_client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/async_client.py deleted file mode 100644 index ce9e2d62..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/async_client.py +++ /dev/null @@ -1,689 +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.dialogflowcx_v3 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.cloud.dialogflowcx_v3.services.deployments import pagers -from google.cloud.dialogflowcx_v3.types import deployment -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import DeploymentsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import DeploymentsGrpcAsyncIOTransport -from .client import DeploymentsClient - - -class DeploymentsAsyncClient: - """Service for managing - [Deployments][google.cloud.dialogflow.cx.v3.Deployment]. - """ - - _client: DeploymentsClient - - DEFAULT_ENDPOINT = DeploymentsClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = DeploymentsClient.DEFAULT_MTLS_ENDPOINT - - deployment_path = staticmethod(DeploymentsClient.deployment_path) - parse_deployment_path = staticmethod(DeploymentsClient.parse_deployment_path) - experiment_path = staticmethod(DeploymentsClient.experiment_path) - parse_experiment_path = staticmethod(DeploymentsClient.parse_experiment_path) - test_case_result_path = staticmethod(DeploymentsClient.test_case_result_path) - parse_test_case_result_path = staticmethod(DeploymentsClient.parse_test_case_result_path) - version_path = staticmethod(DeploymentsClient.version_path) - parse_version_path = staticmethod(DeploymentsClient.parse_version_path) - common_billing_account_path = staticmethod(DeploymentsClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(DeploymentsClient.parse_common_billing_account_path) - common_folder_path = staticmethod(DeploymentsClient.common_folder_path) - parse_common_folder_path = staticmethod(DeploymentsClient.parse_common_folder_path) - common_organization_path = staticmethod(DeploymentsClient.common_organization_path) - parse_common_organization_path = staticmethod(DeploymentsClient.parse_common_organization_path) - common_project_path = staticmethod(DeploymentsClient.common_project_path) - parse_common_project_path = staticmethod(DeploymentsClient.parse_common_project_path) - common_location_path = staticmethod(DeploymentsClient.common_location_path) - parse_common_location_path = staticmethod(DeploymentsClient.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: - DeploymentsAsyncClient: The constructed client. - """ - return DeploymentsClient.from_service_account_info.__func__(DeploymentsAsyncClient, 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: - DeploymentsAsyncClient: The constructed client. - """ - return DeploymentsClient.from_service_account_file.__func__(DeploymentsAsyncClient, 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 DeploymentsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> DeploymentsTransport: - """Returns the transport used by the client instance. - - Returns: - DeploymentsTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(DeploymentsClient).get_transport_class, type(DeploymentsClient)) - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, DeploymentsTransport] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the deployments 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, ~.DeploymentsTransport]): 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 = DeploymentsClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def list_deployments(self, - request: Optional[Union[deployment.ListDeploymentsRequest, 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.ListDeploymentsAsyncPager: - r"""Returns the list of all deployments in the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - .. 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 dialogflowcx_v3 - - async def sample_list_deployments(): - # Create a client - client = dialogflowcx_v3.DeploymentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListDeploymentsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_deployments(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ListDeploymentsRequest, dict]]): - The request object. The request message for - [Deployments.ListDeployments][google.cloud.dialogflow.cx.v3.Deployments.ListDeployments]. - parent (:class:`str`): - Required. The - [Environment][google.cloud.dialogflow.cx.v3.Environment] - to list all environments for. Format: - ``projects//locations//agents//environments/``. - - 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.dialogflowcx_v3.services.deployments.pagers.ListDeploymentsAsyncPager: - The response message for - [Deployments.ListDeployments][google.cloud.dialogflow.cx.v3.Deployments.ListDeployments]. - - 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 = deployment.ListDeploymentsRequest(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_deployments, - 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.ListDeploymentsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_deployment(self, - request: Optional[Union[deployment.GetDeploymentRequest, 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]] = (), - ) -> deployment.Deployment: - r"""Retrieves the specified - [Deployment][google.cloud.dialogflow.cx.v3.Deployment]. - - .. 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 dialogflowcx_v3 - - async def sample_get_deployment(): - # Create a client - client = dialogflowcx_v3.DeploymentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetDeploymentRequest( - name="name_value", - ) - - # Make the request - response = await client.get_deployment(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.GetDeploymentRequest, dict]]): - The request object. The request message for - [Deployments.GetDeployment][google.cloud.dialogflow.cx.v3.Deployments.GetDeployment]. - name (:class:`str`): - Required. The name of the - [Deployment][google.cloud.dialogflow.cx.v3.Deployment]. - Format: - ``projects//locations//agents//environments//deployments/``. - - 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.dialogflowcx_v3.types.Deployment: - Represents a deployment in an - environment. A deployment happens when a - flow version configured to be active in - the environment. You can configure - running pre-deployment steps, e.g. - running validation test cases, - experiment auto-rollout, etc. - - """ - # 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 = deployment.GetDeploymentRequest(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_deployment, - 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_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 get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**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_location, - 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_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**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_locations, - 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 __aenter__(self) -> "DeploymentsAsyncClient": - 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__ = ( - "DeploymentsAsyncClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/client.py deleted file mode 100644 index ce4c0a05..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/client.py +++ /dev/null @@ -1,915 +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.dialogflowcx_v3 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.cloud.dialogflowcx_v3.services.deployments import pagers -from google.cloud.dialogflowcx_v3.types import deployment -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import DeploymentsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import DeploymentsGrpcTransport -from .transports.grpc_asyncio import DeploymentsGrpcAsyncIOTransport -from .transports.rest import DeploymentsRestTransport - - -class DeploymentsClientMeta(type): - """Metaclass for the Deployments 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[DeploymentsTransport]] - _transport_registry["grpc"] = DeploymentsGrpcTransport - _transport_registry["grpc_asyncio"] = DeploymentsGrpcAsyncIOTransport - _transport_registry["rest"] = DeploymentsRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[DeploymentsTransport]: - """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 DeploymentsClient(metaclass=DeploymentsClientMeta): - """Service for managing - [Deployments][google.cloud.dialogflow.cx.v3.Deployment]. - """ - - @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 = "dialogflow.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: - DeploymentsClient: 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: - DeploymentsClient: 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) -> DeploymentsTransport: - """Returns the transport used by the client instance. - - Returns: - DeploymentsTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def deployment_path(project: str,location: str,agent: str,environment: str,deployment: str,) -> str: - """Returns a fully-qualified deployment string.""" - return "projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/deployments/{deployment}".format(project=project, location=location, agent=agent, environment=environment, deployment=deployment, ) - - @staticmethod - def parse_deployment_path(path: str) -> Dict[str,str]: - """Parses a deployment path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/environments/(?P.+?)/deployments/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def experiment_path(project: str,location: str,agent: str,environment: str,experiment: str,) -> str: - """Returns a fully-qualified experiment string.""" - return "projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/experiments/{experiment}".format(project=project, location=location, agent=agent, environment=environment, experiment=experiment, ) - - @staticmethod - def parse_experiment_path(path: str) -> Dict[str,str]: - """Parses a experiment path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/environments/(?P.+?)/experiments/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def test_case_result_path(project: str,location: str,agent: str,test_case: str,result: str,) -> str: - """Returns a fully-qualified test_case_result string.""" - return "projects/{project}/locations/{location}/agents/{agent}/testCases/{test_case}/results/{result}".format(project=project, location=location, agent=agent, test_case=test_case, result=result, ) - - @staticmethod - def parse_test_case_result_path(path: str) -> Dict[str,str]: - """Parses a test_case_result path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/testCases/(?P.+?)/results/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def version_path(project: str,location: str,agent: str,flow: str,version: str,) -> str: - """Returns a fully-qualified version string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version}".format(project=project, location=location, agent=agent, flow=flow, version=version, ) - - @staticmethod - def parse_version_path(path: str) -> Dict[str,str]: - """Parses a version path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)/versions/(?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, DeploymentsTransport]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the deployments 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, DeploymentsTransport]): 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, DeploymentsTransport): - # transport is a DeploymentsTransport 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 list_deployments(self, - request: Optional[Union[deployment.ListDeploymentsRequest, 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.ListDeploymentsPager: - r"""Returns the list of all deployments in the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - .. 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 dialogflowcx_v3 - - def sample_list_deployments(): - # Create a client - client = dialogflowcx_v3.DeploymentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListDeploymentsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_deployments(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ListDeploymentsRequest, dict]): - The request object. The request message for - [Deployments.ListDeployments][google.cloud.dialogflow.cx.v3.Deployments.ListDeployments]. - parent (str): - Required. The - [Environment][google.cloud.dialogflow.cx.v3.Environment] - to list all environments for. Format: - ``projects//locations//agents//environments/``. - - 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.dialogflowcx_v3.services.deployments.pagers.ListDeploymentsPager: - The response message for - [Deployments.ListDeployments][google.cloud.dialogflow.cx.v3.Deployments.ListDeployments]. - - 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 deployment.ListDeploymentsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, deployment.ListDeploymentsRequest): - request = deployment.ListDeploymentsRequest(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_deployments] - - # 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.ListDeploymentsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_deployment(self, - request: Optional[Union[deployment.GetDeploymentRequest, 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]] = (), - ) -> deployment.Deployment: - r"""Retrieves the specified - [Deployment][google.cloud.dialogflow.cx.v3.Deployment]. - - .. 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 dialogflowcx_v3 - - def sample_get_deployment(): - # Create a client - client = dialogflowcx_v3.DeploymentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetDeploymentRequest( - name="name_value", - ) - - # Make the request - response = client.get_deployment(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.GetDeploymentRequest, dict]): - The request object. The request message for - [Deployments.GetDeployment][google.cloud.dialogflow.cx.v3.Deployments.GetDeployment]. - name (str): - Required. The name of the - [Deployment][google.cloud.dialogflow.cx.v3.Deployment]. - Format: - ``projects//locations//agents//environments//deployments/``. - - 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.dialogflowcx_v3.types.Deployment: - Represents a deployment in an - environment. A deployment happens when a - flow version configured to be active in - the environment. You can configure - running pre-deployment steps, e.g. - running validation test cases, - experiment auto-rollout, etc. - - """ - # 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 deployment.GetDeploymentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, deployment.GetDeploymentRequest): - request = deployment.GetDeploymentRequest(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_deployment] - - # 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 __enter__(self) -> "DeploymentsClient": - 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,) - - def get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.get_location, - 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 list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.list_locations, - 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 - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "DeploymentsClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/pagers.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/pagers.py deleted file mode 100644 index e2507b61..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/pagers.py +++ /dev/null @@ -1,139 +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.dialogflowcx_v3.types import deployment - - -class ListDeploymentsPager: - """A pager for iterating through ``list_deployments`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListDeploymentsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``deployments`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListDeployments`` requests and continue to iterate - through the ``deployments`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListDeploymentsResponse` - 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[..., deployment.ListDeploymentsResponse], - request: deployment.ListDeploymentsRequest, - response: deployment.ListDeploymentsResponse, - *, - 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.dialogflowcx_v3.types.ListDeploymentsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListDeploymentsResponse): - 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 = deployment.ListDeploymentsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[deployment.ListDeploymentsResponse]: - 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[deployment.Deployment]: - for page in self.pages: - yield from page.deployments - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListDeploymentsAsyncPager: - """A pager for iterating through ``list_deployments`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListDeploymentsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``deployments`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListDeployments`` requests and continue to iterate - through the ``deployments`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListDeploymentsResponse` - 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[deployment.ListDeploymentsResponse]], - request: deployment.ListDeploymentsRequest, - response: deployment.ListDeploymentsResponse, - *, - 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.dialogflowcx_v3.types.ListDeploymentsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListDeploymentsResponse): - 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 = deployment.ListDeploymentsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[deployment.ListDeploymentsResponse]: - 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[deployment.Deployment]: - async def async_generator(): - async for page in self.pages: - for response in page.deployments: - 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/v3/google/cloud/dialogflowcx_v3/services/deployments/transports/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/transports/__init__.py deleted file mode 100644 index 9f45a71d..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/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 DeploymentsTransport -from .grpc import DeploymentsGrpcTransport -from .grpc_asyncio import DeploymentsGrpcAsyncIOTransport -from .rest import DeploymentsRestTransport -from .rest import DeploymentsRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[DeploymentsTransport]] -_transport_registry['grpc'] = DeploymentsGrpcTransport -_transport_registry['grpc_asyncio'] = DeploymentsGrpcAsyncIOTransport -_transport_registry['rest'] = DeploymentsRestTransport - -__all__ = ( - 'DeploymentsTransport', - 'DeploymentsGrpcTransport', - 'DeploymentsGrpcAsyncIOTransport', - 'DeploymentsRestTransport', - 'DeploymentsRestInterceptor', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/transports/base.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/transports/base.py deleted file mode 100644 index dd07409c..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/transports/base.py +++ /dev/null @@ -1,208 +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.dialogflowcx_v3 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.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.dialogflowcx_v3.types import deployment -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -class DeploymentsTransport(abc.ABC): - """Abstract transport class for Deployments.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/dialogflow', - ) - - DEFAULT_HOST: str = 'dialogflow.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.list_deployments: gapic_v1.method.wrap_method( - self.list_deployments, - default_timeout=None, - client_info=client_info, - ), - self.get_deployment: gapic_v1.method.wrap_method( - self.get_deployment, - 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 list_deployments(self) -> Callable[ - [deployment.ListDeploymentsRequest], - Union[ - deployment.ListDeploymentsResponse, - Awaitable[deployment.ListDeploymentsResponse] - ]]: - raise NotImplementedError() - - @property - def get_deployment(self) -> Callable[ - [deployment.GetDeploymentRequest], - Union[ - deployment.Deployment, - Awaitable[deployment.Deployment] - ]]: - 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 get_location(self, - ) -> Callable[ - [locations_pb2.GetLocationRequest], - Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], - ]: - raise NotImplementedError() - - @property - def list_locations(self, - ) -> Callable[ - [locations_pb2.ListLocationsRequest], - Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'DeploymentsTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/transports/grpc.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/transports/grpc.py deleted file mode 100644 index 1cfc3008..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/transports/grpc.py +++ /dev/null @@ -1,385 +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 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.dialogflowcx_v3.types import deployment -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from .base import DeploymentsTransport, DEFAULT_CLIENT_INFO - - -class DeploymentsGrpcTransport(DeploymentsTransport): - """gRPC backend transport for Deployments. - - Service for managing - [Deployments][google.cloud.dialogflow.cx.v3.Deployment]. - - 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 = 'dialogflow.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] = {} - - 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 = 'dialogflow.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 list_deployments(self) -> Callable[ - [deployment.ListDeploymentsRequest], - deployment.ListDeploymentsResponse]: - r"""Return a callable for the list deployments method over gRPC. - - Returns the list of all deployments in the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - Returns: - Callable[[~.ListDeploymentsRequest], - ~.ListDeploymentsResponse]: - 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_deployments' not in self._stubs: - self._stubs['list_deployments'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Deployments/ListDeployments', - request_serializer=deployment.ListDeploymentsRequest.serialize, - response_deserializer=deployment.ListDeploymentsResponse.deserialize, - ) - return self._stubs['list_deployments'] - - @property - def get_deployment(self) -> Callable[ - [deployment.GetDeploymentRequest], - deployment.Deployment]: - r"""Return a callable for the get deployment method over gRPC. - - Retrieves the specified - [Deployment][google.cloud.dialogflow.cx.v3.Deployment]. - - Returns: - Callable[[~.GetDeploymentRequest], - ~.Deployment]: - 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_deployment' not in self._stubs: - self._stubs['get_deployment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Deployments/GetDeployment', - request_serializer=deployment.GetDeploymentRequest.serialize, - response_deserializer=deployment.Deployment.deserialize, - ) - return self._stubs['get_deployment'] - - 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 list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'DeploymentsGrpcTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/transports/grpc_asyncio.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/transports/grpc_asyncio.py deleted file mode 100644 index b38419cb..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/transports/grpc_asyncio.py +++ /dev/null @@ -1,384 +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.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.dialogflowcx_v3.types import deployment -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from .base import DeploymentsTransport, DEFAULT_CLIENT_INFO -from .grpc import DeploymentsGrpcTransport - - -class DeploymentsGrpcAsyncIOTransport(DeploymentsTransport): - """gRPC AsyncIO backend transport for Deployments. - - Service for managing - [Deployments][google.cloud.dialogflow.cx.v3.Deployment]. - - 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 = 'dialogflow.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 = 'dialogflow.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] = {} - - 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 list_deployments(self) -> Callable[ - [deployment.ListDeploymentsRequest], - Awaitable[deployment.ListDeploymentsResponse]]: - r"""Return a callable for the list deployments method over gRPC. - - Returns the list of all deployments in the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - Returns: - Callable[[~.ListDeploymentsRequest], - Awaitable[~.ListDeploymentsResponse]]: - 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_deployments' not in self._stubs: - self._stubs['list_deployments'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Deployments/ListDeployments', - request_serializer=deployment.ListDeploymentsRequest.serialize, - response_deserializer=deployment.ListDeploymentsResponse.deserialize, - ) - return self._stubs['list_deployments'] - - @property - def get_deployment(self) -> Callable[ - [deployment.GetDeploymentRequest], - Awaitable[deployment.Deployment]]: - r"""Return a callable for the get deployment method over gRPC. - - Retrieves the specified - [Deployment][google.cloud.dialogflow.cx.v3.Deployment]. - - Returns: - Callable[[~.GetDeploymentRequest], - Awaitable[~.Deployment]]: - 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_deployment' not in self._stubs: - self._stubs['get_deployment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Deployments/GetDeployment', - request_serializer=deployment.GetDeploymentRequest.serialize, - response_deserializer=deployment.Deployment.deserialize, - ) - return self._stubs['get_deployment'] - - 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"] - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - -__all__ = ( - 'DeploymentsGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/transports/rest.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/transports/rest.py deleted file mode 100644 index f75eb6f6..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/deployments/transports/rest.py +++ /dev/null @@ -1,844 +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.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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.dialogflowcx_v3.types import deployment - -from .base import DeploymentsTransport, 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 DeploymentsRestInterceptor: - """Interceptor for Deployments. - - 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 DeploymentsRestTransport. - - .. code-block:: python - class MyCustomDeploymentsInterceptor(DeploymentsRestInterceptor): - def pre_get_deployment(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_deployment(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_deployments(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_deployments(self, response): - logging.log(f"Received response: {response}") - return response - - transport = DeploymentsRestTransport(interceptor=MyCustomDeploymentsInterceptor()) - client = DeploymentsClient(transport=transport) - - - """ - def pre_get_deployment(self, request: deployment.GetDeploymentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[deployment.GetDeploymentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_deployment - - Override in a subclass to manipulate the request or metadata - before they are sent to the Deployments server. - """ - return request, metadata - - def post_get_deployment(self, response: deployment.Deployment) -> deployment.Deployment: - """Post-rpc interceptor for get_deployment - - Override in a subclass to manipulate the response - after it is returned by the Deployments server but before - it is returned to user code. - """ - return response - def pre_list_deployments(self, request: deployment.ListDeploymentsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[deployment.ListDeploymentsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_deployments - - Override in a subclass to manipulate the request or metadata - before they are sent to the Deployments server. - """ - return request, metadata - - def post_list_deployments(self, response: deployment.ListDeploymentsResponse) -> deployment.ListDeploymentsResponse: - """Post-rpc interceptor for list_deployments - - Override in a subclass to manipulate the response - after it is returned by the Deployments server but before - it is returned to user code. - """ - return response - - def pre_get_location( - self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_location - - Override in a subclass to manipulate the request or metadata - before they are sent to the Deployments server. - """ - return request, metadata - - def post_get_location( - self, response: locations_pb2.Location - ) -> locations_pb2.Location: - """Post-rpc interceptor for get_location - - Override in a subclass to manipulate the response - after it is returned by the Deployments server but before - it is returned to user code. - """ - return response - def pre_list_locations( - self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_locations - - Override in a subclass to manipulate the request or metadata - before they are sent to the Deployments server. - """ - return request, metadata - - def post_list_locations( - self, response: locations_pb2.ListLocationsResponse - ) -> locations_pb2.ListLocationsResponse: - """Post-rpc interceptor for list_locations - - Override in a subclass to manipulate the response - after it is returned by the Deployments 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 Deployments 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 Deployments 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 Deployments 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 Deployments 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 Deployments 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 Deployments server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class DeploymentsRestStub: - _session: AuthorizedSession - _host: str - _interceptor: DeploymentsRestInterceptor - - -class DeploymentsRestTransport(DeploymentsTransport): - """REST backend transport for Deployments. - - Service for managing - [Deployments][google.cloud.dialogflow.cx.v3.Deployment]. - - 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 = 'dialogflow.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[DeploymentsRestInterceptor] = 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) - if client_cert_source_for_mtls: - self._session.configure_mtls_channel(client_cert_source_for_mtls) - self._interceptor = interceptor or DeploymentsRestInterceptor() - self._prep_wrapped_messages(client_info) - - class _GetDeployment(DeploymentsRestStub): - def __hash__(self): - return hash("GetDeployment") - - __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: deployment.GetDeploymentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> deployment.Deployment: - r"""Call the get deployment method over HTTP. - - Args: - request (~.deployment.GetDeploymentRequest): - The request object. The request message for - [Deployments.GetDeployment][google.cloud.dialogflow.cx.v3.Deployments.GetDeployment]. - 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: - ~.deployment.Deployment: - Represents a deployment in an - environment. A deployment happens when a - flow version configured to be active in - the environment. You can configure - running pre-deployment steps, e.g. - running validation test cases, - experiment auto-rollout, etc. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/environments/*/deployments/*}', - }, - ] - request, metadata = self._interceptor.pre_get_deployment(request, metadata) - pb_request = deployment.GetDeploymentRequest.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 = deployment.Deployment() - pb_resp = deployment.Deployment.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_deployment(resp) - return resp - - class _ListDeployments(DeploymentsRestStub): - def __hash__(self): - return hash("ListDeployments") - - __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: deployment.ListDeploymentsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> deployment.ListDeploymentsResponse: - r"""Call the list deployments method over HTTP. - - Args: - request (~.deployment.ListDeploymentsRequest): - The request object. The request message for - [Deployments.ListDeployments][google.cloud.dialogflow.cx.v3.Deployments.ListDeployments]. - 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: - ~.deployment.ListDeploymentsResponse: - The response message for - [Deployments.ListDeployments][google.cloud.dialogflow.cx.v3.Deployments.ListDeployments]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*/environments/*}/deployments', - }, - ] - request, metadata = self._interceptor.pre_list_deployments(request, metadata) - pb_request = deployment.ListDeploymentsRequest.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 = deployment.ListDeploymentsResponse() - pb_resp = deployment.ListDeploymentsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_deployments(resp) - return resp - - @property - def get_deployment(self) -> Callable[ - [deployment.GetDeploymentRequest], - deployment.Deployment]: - # 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._GetDeployment(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_deployments(self) -> Callable[ - [deployment.ListDeploymentsRequest], - deployment.ListDeploymentsResponse]: - # 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._ListDeployments(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_location(self): - return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore - - class _GetLocation(DeploymentsRestStub): - def __call__(self, - request: locations_pb2.GetLocationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.Location: - - r"""Call the get location method over HTTP. - - Args: - request (locations_pb2.GetLocationRequest): - The request object for GetLocation 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: - locations_pb2.Location: Response from GetLocation method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*}', - }, - ] - - request, metadata = self._interceptor.pre_get_location(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 = locations_pb2.Location() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_get_location(resp) - return resp - - @property - def list_locations(self): - return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore - - class _ListLocations(DeploymentsRestStub): - def __call__(self, - request: locations_pb2.ListLocationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.ListLocationsResponse: - - r"""Call the list locations method over HTTP. - - Args: - request (locations_pb2.ListLocationsRequest): - The request object for ListLocations 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: - locations_pb2.ListLocationsResponse: Response from ListLocations method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*}/locations', - }, - ] - - request, metadata = self._interceptor.pre_list_locations(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 = locations_pb2.ListLocationsResponse() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_list_locations(resp) - return resp - - @property - def cancel_operation(self): - return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore - - class _CancelOperation(DeploymentsRestStub): - 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': '/v3/{name=projects/*/operations/*}:cancel', - }, -{ - 'method': 'post', - 'uri': '/v3/{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(DeploymentsRestStub): - 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': '/v3/{name=projects/*/operations/*}', - }, -{ - 'method': 'get', - 'uri': '/v3/{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(DeploymentsRestStub): - 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': '/v3/{name=projects/*}/operations', - }, -{ - 'method': 'get', - 'uri': '/v3/{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__=( - 'DeploymentsRestTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/__init__.py deleted file mode 100644 index 3b60db19..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/__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 EntityTypesClient -from .async_client import EntityTypesAsyncClient - -__all__ = ( - 'EntityTypesClient', - 'EntityTypesAsyncClient', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/async_client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/async_client.py deleted file mode 100644 index fa41febd..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/async_client.py +++ /dev/null @@ -1,1099 +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.dialogflowcx_v3 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.cloud.dialogflowcx_v3.services.entity_types import pagers -from google.cloud.dialogflowcx_v3.types import entity_type -from google.cloud.dialogflowcx_v3.types import entity_type as gcdc_entity_type -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import EntityTypesTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import EntityTypesGrpcAsyncIOTransport -from .client import EntityTypesClient - - -class EntityTypesAsyncClient: - """Service for managing - [EntityTypes][google.cloud.dialogflow.cx.v3.EntityType]. - """ - - _client: EntityTypesClient - - DEFAULT_ENDPOINT = EntityTypesClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = EntityTypesClient.DEFAULT_MTLS_ENDPOINT - - entity_type_path = staticmethod(EntityTypesClient.entity_type_path) - parse_entity_type_path = staticmethod(EntityTypesClient.parse_entity_type_path) - common_billing_account_path = staticmethod(EntityTypesClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(EntityTypesClient.parse_common_billing_account_path) - common_folder_path = staticmethod(EntityTypesClient.common_folder_path) - parse_common_folder_path = staticmethod(EntityTypesClient.parse_common_folder_path) - common_organization_path = staticmethod(EntityTypesClient.common_organization_path) - parse_common_organization_path = staticmethod(EntityTypesClient.parse_common_organization_path) - common_project_path = staticmethod(EntityTypesClient.common_project_path) - parse_common_project_path = staticmethod(EntityTypesClient.parse_common_project_path) - common_location_path = staticmethod(EntityTypesClient.common_location_path) - parse_common_location_path = staticmethod(EntityTypesClient.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: - EntityTypesAsyncClient: The constructed client. - """ - return EntityTypesClient.from_service_account_info.__func__(EntityTypesAsyncClient, 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: - EntityTypesAsyncClient: The constructed client. - """ - return EntityTypesClient.from_service_account_file.__func__(EntityTypesAsyncClient, 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 EntityTypesClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> EntityTypesTransport: - """Returns the transport used by the client instance. - - Returns: - EntityTypesTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(EntityTypesClient).get_transport_class, type(EntityTypesClient)) - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, EntityTypesTransport] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the entity types 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, ~.EntityTypesTransport]): 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 = EntityTypesClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def list_entity_types(self, - request: Optional[Union[entity_type.ListEntityTypesRequest, 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.ListEntityTypesAsyncPager: - r"""Returns the list of all entity types in the specified - agent. - - .. 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 dialogflowcx_v3 - - async def sample_list_entity_types(): - # Create a client - client = dialogflowcx_v3.EntityTypesAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListEntityTypesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_entity_types(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ListEntityTypesRequest, dict]]): - The request object. The request message for - [EntityTypes.ListEntityTypes][google.cloud.dialogflow.cx.v3.EntityTypes.ListEntityTypes]. - parent (:class:`str`): - Required. The agent to list all entity types for. - Format: - ``projects//locations//agents/``. - - 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.dialogflowcx_v3.services.entity_types.pagers.ListEntityTypesAsyncPager: - The response message for - [EntityTypes.ListEntityTypes][google.cloud.dialogflow.cx.v3.EntityTypes.ListEntityTypes]. - - 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 = entity_type.ListEntityTypesRequest(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_entity_types, - 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.ListEntityTypesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_entity_type(self, - request: Optional[Union[entity_type.GetEntityTypeRequest, 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]] = (), - ) -> entity_type.EntityType: - r"""Retrieves the specified entity type. - - .. 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 dialogflowcx_v3 - - async def sample_get_entity_type(): - # Create a client - client = dialogflowcx_v3.EntityTypesAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetEntityTypeRequest( - name="name_value", - ) - - # Make the request - response = await client.get_entity_type(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.GetEntityTypeRequest, dict]]): - The request object. The request message for - [EntityTypes.GetEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.GetEntityType]. - name (:class:`str`): - Required. The name of the entity type. Format: - ``projects//locations//agents//entityTypes/``. - - 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.dialogflowcx_v3.types.EntityType: - Entities are extracted from user input and represent parameters that are - meaningful to your application. For example, a date - range, a proper name such as a geographic location or - landmark, and so on. Entities represent actionable - data for your application. - - When you define an entity, you can also include - synonyms that all map to that entity. For example, - "soft drink", "soda", "pop", and so on. - - There are three types of entities: - - - **System** - entities that are defined by the - Dialogflow API for common data types such as date, - time, currency, and so on. A system entity is - represented by the EntityType type. - - **Custom** - entities that are defined by you that - represent actionable data that is meaningful to - your application. For example, you could define a - pizza.sauce entity for red or white pizza sauce, a - pizza.cheese entity for the different types of - cheese on a pizza, a pizza.topping entity for - different toppings, and so on. A custom entity is - represented by the EntityType type. - - **User** - entities that are built for an - individual user such as favorites, preferences, - playlists, and so on. A user entity is represented - by the - [SessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityType] - type. - - For more information about entity types, see the - [Dialogflow - documentation](\ https://cloud.google.com/dialogflow/docs/entities-overview). - - """ - # 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 = entity_type.GetEntityTypeRequest(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_entity_type, - 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 create_entity_type(self, - request: Optional[Union[gcdc_entity_type.CreateEntityTypeRequest, dict]] = None, - *, - parent: Optional[str] = None, - entity_type: Optional[gcdc_entity_type.EntityType] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_entity_type.EntityType: - r"""Creates an entity type in the specified agent. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - async def sample_create_entity_type(): - # Create a client - client = dialogflowcx_v3.EntityTypesAsyncClient() - - # Initialize request argument(s) - entity_type = dialogflowcx_v3.EntityType() - entity_type.display_name = "display_name_value" - entity_type.kind = "KIND_REGEXP" - - request = dialogflowcx_v3.CreateEntityTypeRequest( - parent="parent_value", - entity_type=entity_type, - ) - - # Make the request - response = await client.create_entity_type(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.CreateEntityTypeRequest, dict]]): - The request object. The request message for - [EntityTypes.CreateEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.CreateEntityType]. - parent (:class:`str`): - Required. The agent to create a entity type for. Format: - ``projects//locations//agents/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - entity_type (:class:`google.cloud.dialogflowcx_v3.types.EntityType`): - Required. The entity type to create. - This corresponds to the ``entity_type`` 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.dialogflowcx_v3.types.EntityType: - Entities are extracted from user input and represent parameters that are - meaningful to your application. For example, a date - range, a proper name such as a geographic location or - landmark, and so on. Entities represent actionable - data for your application. - - When you define an entity, you can also include - synonyms that all map to that entity. For example, - "soft drink", "soda", "pop", and so on. - - There are three types of entities: - - - **System** - entities that are defined by the - Dialogflow API for common data types such as date, - time, currency, and so on. A system entity is - represented by the EntityType type. - - **Custom** - entities that are defined by you that - represent actionable data that is meaningful to - your application. For example, you could define a - pizza.sauce entity for red or white pizza sauce, a - pizza.cheese entity for the different types of - cheese on a pizza, a pizza.topping entity for - different toppings, and so on. A custom entity is - represented by the EntityType type. - - **User** - entities that are built for an - individual user such as favorites, preferences, - playlists, and so on. A user entity is represented - by the - [SessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityType] - type. - - For more information about entity types, see the - [Dialogflow - documentation](\ https://cloud.google.com/dialogflow/docs/entities-overview). - - """ - # 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, entity_type]) - 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 = gcdc_entity_type.CreateEntityTypeRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if entity_type is not None: - request.entity_type = entity_type - - # 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_entity_type, - 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_entity_type(self, - request: Optional[Union[gcdc_entity_type.UpdateEntityTypeRequest, dict]] = None, - *, - entity_type: Optional[gcdc_entity_type.EntityType] = 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]] = (), - ) -> gcdc_entity_type.EntityType: - r"""Updates the specified entity type. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - async def sample_update_entity_type(): - # Create a client - client = dialogflowcx_v3.EntityTypesAsyncClient() - - # Initialize request argument(s) - entity_type = dialogflowcx_v3.EntityType() - entity_type.display_name = "display_name_value" - entity_type.kind = "KIND_REGEXP" - - request = dialogflowcx_v3.UpdateEntityTypeRequest( - entity_type=entity_type, - ) - - # Make the request - response = await client.update_entity_type(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.UpdateEntityTypeRequest, dict]]): - The request object. The request message for - [EntityTypes.UpdateEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.UpdateEntityType]. - entity_type (:class:`google.cloud.dialogflowcx_v3.types.EntityType`): - Required. The entity type to update. - This corresponds to the ``entity_type`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The mask to control which fields get - 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.dialogflowcx_v3.types.EntityType: - Entities are extracted from user input and represent parameters that are - meaningful to your application. For example, a date - range, a proper name such as a geographic location or - landmark, and so on. Entities represent actionable - data for your application. - - When you define an entity, you can also include - synonyms that all map to that entity. For example, - "soft drink", "soda", "pop", and so on. - - There are three types of entities: - - - **System** - entities that are defined by the - Dialogflow API for common data types such as date, - time, currency, and so on. A system entity is - represented by the EntityType type. - - **Custom** - entities that are defined by you that - represent actionable data that is meaningful to - your application. For example, you could define a - pizza.sauce entity for red or white pizza sauce, a - pizza.cheese entity for the different types of - cheese on a pizza, a pizza.topping entity for - different toppings, and so on. A custom entity is - represented by the EntityType type. - - **User** - entities that are built for an - individual user such as favorites, preferences, - playlists, and so on. A user entity is represented - by the - [SessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityType] - type. - - For more information about entity types, see the - [Dialogflow - documentation](\ https://cloud.google.com/dialogflow/docs/entities-overview). - - """ - # 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([entity_type, 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 = gcdc_entity_type.UpdateEntityTypeRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if entity_type is not None: - request.entity_type = entity_type - 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_entity_type, - 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(( - ("entity_type.name", request.entity_type.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_entity_type(self, - request: Optional[Union[entity_type.DeleteEntityTypeRequest, 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 the specified entity type. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - async def sample_delete_entity_type(): - # Create a client - client = dialogflowcx_v3.EntityTypesAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteEntityTypeRequest( - name="name_value", - ) - - # Make the request - await client.delete_entity_type(request=request) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.DeleteEntityTypeRequest, dict]]): - The request object. The request message for - [EntityTypes.DeleteEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.DeleteEntityType]. - name (:class:`str`): - Required. The name of the entity type to delete. Format: - ``projects//locations//agents//entityTypes/``. - - 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 = entity_type.DeleteEntityTypeRequest(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_entity_type, - 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 get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**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_location, - 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_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**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_locations, - 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 __aenter__(self) -> "EntityTypesAsyncClient": - 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__ = ( - "EntityTypesAsyncClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/client.py deleted file mode 100644 index e69e1f07..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/client.py +++ /dev/null @@ -1,1298 +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.dialogflowcx_v3 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.cloud.dialogflowcx_v3.services.entity_types import pagers -from google.cloud.dialogflowcx_v3.types import entity_type -from google.cloud.dialogflowcx_v3.types import entity_type as gcdc_entity_type -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import EntityTypesTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import EntityTypesGrpcTransport -from .transports.grpc_asyncio import EntityTypesGrpcAsyncIOTransport -from .transports.rest import EntityTypesRestTransport - - -class EntityTypesClientMeta(type): - """Metaclass for the EntityTypes 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[EntityTypesTransport]] - _transport_registry["grpc"] = EntityTypesGrpcTransport - _transport_registry["grpc_asyncio"] = EntityTypesGrpcAsyncIOTransport - _transport_registry["rest"] = EntityTypesRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[EntityTypesTransport]: - """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 EntityTypesClient(metaclass=EntityTypesClientMeta): - """Service for managing - [EntityTypes][google.cloud.dialogflow.cx.v3.EntityType]. - """ - - @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 = "dialogflow.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: - EntityTypesClient: 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: - EntityTypesClient: 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) -> EntityTypesTransport: - """Returns the transport used by the client instance. - - Returns: - EntityTypesTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def entity_type_path(project: str,location: str,agent: str,entity_type: str,) -> str: - """Returns a fully-qualified entity_type string.""" - return "projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type}".format(project=project, location=location, agent=agent, entity_type=entity_type, ) - - @staticmethod - def parse_entity_type_path(path: str) -> Dict[str,str]: - """Parses a entity_type path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/entityTypes/(?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, EntityTypesTransport]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the entity types 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, EntityTypesTransport]): 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, EntityTypesTransport): - # transport is a EntityTypesTransport 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 list_entity_types(self, - request: Optional[Union[entity_type.ListEntityTypesRequest, 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.ListEntityTypesPager: - r"""Returns the list of all entity types in the specified - agent. - - .. 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 dialogflowcx_v3 - - def sample_list_entity_types(): - # Create a client - client = dialogflowcx_v3.EntityTypesClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListEntityTypesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_entity_types(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ListEntityTypesRequest, dict]): - The request object. The request message for - [EntityTypes.ListEntityTypes][google.cloud.dialogflow.cx.v3.EntityTypes.ListEntityTypes]. - parent (str): - Required. The agent to list all entity types for. - Format: - ``projects//locations//agents/``. - - 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.dialogflowcx_v3.services.entity_types.pagers.ListEntityTypesPager: - The response message for - [EntityTypes.ListEntityTypes][google.cloud.dialogflow.cx.v3.EntityTypes.ListEntityTypes]. - - 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 entity_type.ListEntityTypesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, entity_type.ListEntityTypesRequest): - request = entity_type.ListEntityTypesRequest(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_entity_types] - - # 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.ListEntityTypesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_entity_type(self, - request: Optional[Union[entity_type.GetEntityTypeRequest, 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]] = (), - ) -> entity_type.EntityType: - r"""Retrieves the specified entity type. - - .. 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 dialogflowcx_v3 - - def sample_get_entity_type(): - # Create a client - client = dialogflowcx_v3.EntityTypesClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetEntityTypeRequest( - name="name_value", - ) - - # Make the request - response = client.get_entity_type(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.GetEntityTypeRequest, dict]): - The request object. The request message for - [EntityTypes.GetEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.GetEntityType]. - name (str): - Required. The name of the entity type. Format: - ``projects//locations//agents//entityTypes/``. - - 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.dialogflowcx_v3.types.EntityType: - Entities are extracted from user input and represent parameters that are - meaningful to your application. For example, a date - range, a proper name such as a geographic location or - landmark, and so on. Entities represent actionable - data for your application. - - When you define an entity, you can also include - synonyms that all map to that entity. For example, - "soft drink", "soda", "pop", and so on. - - There are three types of entities: - - - **System** - entities that are defined by the - Dialogflow API for common data types such as date, - time, currency, and so on. A system entity is - represented by the EntityType type. - - **Custom** - entities that are defined by you that - represent actionable data that is meaningful to - your application. For example, you could define a - pizza.sauce entity for red or white pizza sauce, a - pizza.cheese entity for the different types of - cheese on a pizza, a pizza.topping entity for - different toppings, and so on. A custom entity is - represented by the EntityType type. - - **User** - entities that are built for an - individual user such as favorites, preferences, - playlists, and so on. A user entity is represented - by the - [SessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityType] - type. - - For more information about entity types, see the - [Dialogflow - documentation](\ https://cloud.google.com/dialogflow/docs/entities-overview). - - """ - # 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 entity_type.GetEntityTypeRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, entity_type.GetEntityTypeRequest): - request = entity_type.GetEntityTypeRequest(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_entity_type] - - # 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 create_entity_type(self, - request: Optional[Union[gcdc_entity_type.CreateEntityTypeRequest, dict]] = None, - *, - parent: Optional[str] = None, - entity_type: Optional[gcdc_entity_type.EntityType] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_entity_type.EntityType: - r"""Creates an entity type in the specified agent. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - def sample_create_entity_type(): - # Create a client - client = dialogflowcx_v3.EntityTypesClient() - - # Initialize request argument(s) - entity_type = dialogflowcx_v3.EntityType() - entity_type.display_name = "display_name_value" - entity_type.kind = "KIND_REGEXP" - - request = dialogflowcx_v3.CreateEntityTypeRequest( - parent="parent_value", - entity_type=entity_type, - ) - - # Make the request - response = client.create_entity_type(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.CreateEntityTypeRequest, dict]): - The request object. The request message for - [EntityTypes.CreateEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.CreateEntityType]. - parent (str): - Required. The agent to create a entity type for. Format: - ``projects//locations//agents/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - entity_type (google.cloud.dialogflowcx_v3.types.EntityType): - Required. The entity type to create. - This corresponds to the ``entity_type`` 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.dialogflowcx_v3.types.EntityType: - Entities are extracted from user input and represent parameters that are - meaningful to your application. For example, a date - range, a proper name such as a geographic location or - landmark, and so on. Entities represent actionable - data for your application. - - When you define an entity, you can also include - synonyms that all map to that entity. For example, - "soft drink", "soda", "pop", and so on. - - There are three types of entities: - - - **System** - entities that are defined by the - Dialogflow API for common data types such as date, - time, currency, and so on. A system entity is - represented by the EntityType type. - - **Custom** - entities that are defined by you that - represent actionable data that is meaningful to - your application. For example, you could define a - pizza.sauce entity for red or white pizza sauce, a - pizza.cheese entity for the different types of - cheese on a pizza, a pizza.topping entity for - different toppings, and so on. A custom entity is - represented by the EntityType type. - - **User** - entities that are built for an - individual user such as favorites, preferences, - playlists, and so on. A user entity is represented - by the - [SessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityType] - type. - - For more information about entity types, see the - [Dialogflow - documentation](\ https://cloud.google.com/dialogflow/docs/entities-overview). - - """ - # 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, entity_type]) - 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 gcdc_entity_type.CreateEntityTypeRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_entity_type.CreateEntityTypeRequest): - request = gcdc_entity_type.CreateEntityTypeRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if entity_type is not None: - request.entity_type = entity_type - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_entity_type] - - # 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_entity_type(self, - request: Optional[Union[gcdc_entity_type.UpdateEntityTypeRequest, dict]] = None, - *, - entity_type: Optional[gcdc_entity_type.EntityType] = 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]] = (), - ) -> gcdc_entity_type.EntityType: - r"""Updates the specified entity type. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - def sample_update_entity_type(): - # Create a client - client = dialogflowcx_v3.EntityTypesClient() - - # Initialize request argument(s) - entity_type = dialogflowcx_v3.EntityType() - entity_type.display_name = "display_name_value" - entity_type.kind = "KIND_REGEXP" - - request = dialogflowcx_v3.UpdateEntityTypeRequest( - entity_type=entity_type, - ) - - # Make the request - response = client.update_entity_type(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.UpdateEntityTypeRequest, dict]): - The request object. The request message for - [EntityTypes.UpdateEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.UpdateEntityType]. - entity_type (google.cloud.dialogflowcx_v3.types.EntityType): - Required. The entity type to update. - This corresponds to the ``entity_type`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The mask to control which fields get - 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.dialogflowcx_v3.types.EntityType: - Entities are extracted from user input and represent parameters that are - meaningful to your application. For example, a date - range, a proper name such as a geographic location or - landmark, and so on. Entities represent actionable - data for your application. - - When you define an entity, you can also include - synonyms that all map to that entity. For example, - "soft drink", "soda", "pop", and so on. - - There are three types of entities: - - - **System** - entities that are defined by the - Dialogflow API for common data types such as date, - time, currency, and so on. A system entity is - represented by the EntityType type. - - **Custom** - entities that are defined by you that - represent actionable data that is meaningful to - your application. For example, you could define a - pizza.sauce entity for red or white pizza sauce, a - pizza.cheese entity for the different types of - cheese on a pizza, a pizza.topping entity for - different toppings, and so on. A custom entity is - represented by the EntityType type. - - **User** - entities that are built for an - individual user such as favorites, preferences, - playlists, and so on. A user entity is represented - by the - [SessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityType] - type. - - For more information about entity types, see the - [Dialogflow - documentation](\ https://cloud.google.com/dialogflow/docs/entities-overview). - - """ - # 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([entity_type, 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 gcdc_entity_type.UpdateEntityTypeRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_entity_type.UpdateEntityTypeRequest): - request = gcdc_entity_type.UpdateEntityTypeRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if entity_type is not None: - request.entity_type = entity_type - 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_entity_type] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("entity_type.name", request.entity_type.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_entity_type(self, - request: Optional[Union[entity_type.DeleteEntityTypeRequest, 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 the specified entity type. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - def sample_delete_entity_type(): - # Create a client - client = dialogflowcx_v3.EntityTypesClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteEntityTypeRequest( - name="name_value", - ) - - # Make the request - client.delete_entity_type(request=request) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.DeleteEntityTypeRequest, dict]): - The request object. The request message for - [EntityTypes.DeleteEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.DeleteEntityType]. - name (str): - Required. The name of the entity type to delete. Format: - ``projects//locations//agents//entityTypes/``. - - 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 entity_type.DeleteEntityTypeRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, entity_type.DeleteEntityTypeRequest): - request = entity_type.DeleteEntityTypeRequest(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_entity_type] - - # 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) -> "EntityTypesClient": - 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,) - - def get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.get_location, - 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 list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.list_locations, - 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 - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "EntityTypesClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/pagers.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/pagers.py deleted file mode 100644 index 4b6da7db..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/pagers.py +++ /dev/null @@ -1,139 +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.dialogflowcx_v3.types import entity_type - - -class ListEntityTypesPager: - """A pager for iterating through ``list_entity_types`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListEntityTypesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``entity_types`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListEntityTypes`` requests and continue to iterate - through the ``entity_types`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListEntityTypesResponse` - 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[..., entity_type.ListEntityTypesResponse], - request: entity_type.ListEntityTypesRequest, - response: entity_type.ListEntityTypesResponse, - *, - 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.dialogflowcx_v3.types.ListEntityTypesRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListEntityTypesResponse): - 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 = entity_type.ListEntityTypesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[entity_type.ListEntityTypesResponse]: - 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[entity_type.EntityType]: - for page in self.pages: - yield from page.entity_types - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListEntityTypesAsyncPager: - """A pager for iterating through ``list_entity_types`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListEntityTypesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``entity_types`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListEntityTypes`` requests and continue to iterate - through the ``entity_types`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListEntityTypesResponse` - 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[entity_type.ListEntityTypesResponse]], - request: entity_type.ListEntityTypesRequest, - response: entity_type.ListEntityTypesResponse, - *, - 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.dialogflowcx_v3.types.ListEntityTypesRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListEntityTypesResponse): - 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 = entity_type.ListEntityTypesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[entity_type.ListEntityTypesResponse]: - 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[entity_type.EntityType]: - async def async_generator(): - async for page in self.pages: - for response in page.entity_types: - 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/v3/google/cloud/dialogflowcx_v3/services/entity_types/transports/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/transports/__init__.py deleted file mode 100644 index 7f048a89..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/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 EntityTypesTransport -from .grpc import EntityTypesGrpcTransport -from .grpc_asyncio import EntityTypesGrpcAsyncIOTransport -from .rest import EntityTypesRestTransport -from .rest import EntityTypesRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[EntityTypesTransport]] -_transport_registry['grpc'] = EntityTypesGrpcTransport -_transport_registry['grpc_asyncio'] = EntityTypesGrpcAsyncIOTransport -_transport_registry['rest'] = EntityTypesRestTransport - -__all__ = ( - 'EntityTypesTransport', - 'EntityTypesGrpcTransport', - 'EntityTypesGrpcAsyncIOTransport', - 'EntityTypesRestTransport', - 'EntityTypesRestInterceptor', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/transports/base.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/transports/base.py deleted file mode 100644 index 6d88f2dc..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/transports/base.py +++ /dev/null @@ -1,252 +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.dialogflowcx_v3 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.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.dialogflowcx_v3.types import entity_type -from google.cloud.dialogflowcx_v3.types import entity_type as gcdc_entity_type -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -class EntityTypesTransport(abc.ABC): - """Abstract transport class for EntityTypes.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/dialogflow', - ) - - DEFAULT_HOST: str = 'dialogflow.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.list_entity_types: gapic_v1.method.wrap_method( - self.list_entity_types, - default_timeout=None, - client_info=client_info, - ), - self.get_entity_type: gapic_v1.method.wrap_method( - self.get_entity_type, - default_timeout=None, - client_info=client_info, - ), - self.create_entity_type: gapic_v1.method.wrap_method( - self.create_entity_type, - default_timeout=None, - client_info=client_info, - ), - self.update_entity_type: gapic_v1.method.wrap_method( - self.update_entity_type, - default_timeout=None, - client_info=client_info, - ), - self.delete_entity_type: gapic_v1.method.wrap_method( - self.delete_entity_type, - 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 list_entity_types(self) -> Callable[ - [entity_type.ListEntityTypesRequest], - Union[ - entity_type.ListEntityTypesResponse, - Awaitable[entity_type.ListEntityTypesResponse] - ]]: - raise NotImplementedError() - - @property - def get_entity_type(self) -> Callable[ - [entity_type.GetEntityTypeRequest], - Union[ - entity_type.EntityType, - Awaitable[entity_type.EntityType] - ]]: - raise NotImplementedError() - - @property - def create_entity_type(self) -> Callable[ - [gcdc_entity_type.CreateEntityTypeRequest], - Union[ - gcdc_entity_type.EntityType, - Awaitable[gcdc_entity_type.EntityType] - ]]: - raise NotImplementedError() - - @property - def update_entity_type(self) -> Callable[ - [gcdc_entity_type.UpdateEntityTypeRequest], - Union[ - gcdc_entity_type.EntityType, - Awaitable[gcdc_entity_type.EntityType] - ]]: - raise NotImplementedError() - - @property - def delete_entity_type(self) -> Callable[ - [entity_type.DeleteEntityTypeRequest], - 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 get_location(self, - ) -> Callable[ - [locations_pb2.GetLocationRequest], - Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], - ]: - raise NotImplementedError() - - @property - def list_locations(self, - ) -> Callable[ - [locations_pb2.ListLocationsRequest], - Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'EntityTypesTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc.py deleted file mode 100644 index 66ce673a..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc.py +++ /dev/null @@ -1,476 +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 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.dialogflowcx_v3.types import entity_type -from google.cloud.dialogflowcx_v3.types import entity_type as gcdc_entity_type -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from .base import EntityTypesTransport, DEFAULT_CLIENT_INFO - - -class EntityTypesGrpcTransport(EntityTypesTransport): - """gRPC backend transport for EntityTypes. - - Service for managing - [EntityTypes][google.cloud.dialogflow.cx.v3.EntityType]. - - 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 = 'dialogflow.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] = {} - - 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 = 'dialogflow.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 list_entity_types(self) -> Callable[ - [entity_type.ListEntityTypesRequest], - entity_type.ListEntityTypesResponse]: - r"""Return a callable for the list entity types method over gRPC. - - Returns the list of all entity types in the specified - agent. - - Returns: - Callable[[~.ListEntityTypesRequest], - ~.ListEntityTypesResponse]: - 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_entity_types' not in self._stubs: - self._stubs['list_entity_types'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.EntityTypes/ListEntityTypes', - request_serializer=entity_type.ListEntityTypesRequest.serialize, - response_deserializer=entity_type.ListEntityTypesResponse.deserialize, - ) - return self._stubs['list_entity_types'] - - @property - def get_entity_type(self) -> Callable[ - [entity_type.GetEntityTypeRequest], - entity_type.EntityType]: - r"""Return a callable for the get entity type method over gRPC. - - Retrieves the specified entity type. - - Returns: - Callable[[~.GetEntityTypeRequest], - ~.EntityType]: - 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_entity_type' not in self._stubs: - self._stubs['get_entity_type'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.EntityTypes/GetEntityType', - request_serializer=entity_type.GetEntityTypeRequest.serialize, - response_deserializer=entity_type.EntityType.deserialize, - ) - return self._stubs['get_entity_type'] - - @property - def create_entity_type(self) -> Callable[ - [gcdc_entity_type.CreateEntityTypeRequest], - gcdc_entity_type.EntityType]: - r"""Return a callable for the create entity type method over gRPC. - - Creates an entity type in the specified agent. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.CreateEntityTypeRequest], - ~.EntityType]: - 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_entity_type' not in self._stubs: - self._stubs['create_entity_type'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.EntityTypes/CreateEntityType', - request_serializer=gcdc_entity_type.CreateEntityTypeRequest.serialize, - response_deserializer=gcdc_entity_type.EntityType.deserialize, - ) - return self._stubs['create_entity_type'] - - @property - def update_entity_type(self) -> Callable[ - [gcdc_entity_type.UpdateEntityTypeRequest], - gcdc_entity_type.EntityType]: - r"""Return a callable for the update entity type method over gRPC. - - Updates the specified entity type. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.UpdateEntityTypeRequest], - ~.EntityType]: - 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_entity_type' not in self._stubs: - self._stubs['update_entity_type'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.EntityTypes/UpdateEntityType', - request_serializer=gcdc_entity_type.UpdateEntityTypeRequest.serialize, - response_deserializer=gcdc_entity_type.EntityType.deserialize, - ) - return self._stubs['update_entity_type'] - - @property - def delete_entity_type(self) -> Callable[ - [entity_type.DeleteEntityTypeRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete entity type method over gRPC. - - Deletes the specified entity type. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.DeleteEntityTypeRequest], - ~.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_entity_type' not in self._stubs: - self._stubs['delete_entity_type'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.EntityTypes/DeleteEntityType', - request_serializer=entity_type.DeleteEntityTypeRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_entity_type'] - - 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 list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'EntityTypesGrpcTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc_asyncio.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc_asyncio.py deleted file mode 100644 index 0a9cf512..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc_asyncio.py +++ /dev/null @@ -1,475 +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.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.dialogflowcx_v3.types import entity_type -from google.cloud.dialogflowcx_v3.types import entity_type as gcdc_entity_type -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from .base import EntityTypesTransport, DEFAULT_CLIENT_INFO -from .grpc import EntityTypesGrpcTransport - - -class EntityTypesGrpcAsyncIOTransport(EntityTypesTransport): - """gRPC AsyncIO backend transport for EntityTypes. - - Service for managing - [EntityTypes][google.cloud.dialogflow.cx.v3.EntityType]. - - 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 = 'dialogflow.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 = 'dialogflow.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] = {} - - 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 list_entity_types(self) -> Callable[ - [entity_type.ListEntityTypesRequest], - Awaitable[entity_type.ListEntityTypesResponse]]: - r"""Return a callable for the list entity types method over gRPC. - - Returns the list of all entity types in the specified - agent. - - Returns: - Callable[[~.ListEntityTypesRequest], - Awaitable[~.ListEntityTypesResponse]]: - 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_entity_types' not in self._stubs: - self._stubs['list_entity_types'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.EntityTypes/ListEntityTypes', - request_serializer=entity_type.ListEntityTypesRequest.serialize, - response_deserializer=entity_type.ListEntityTypesResponse.deserialize, - ) - return self._stubs['list_entity_types'] - - @property - def get_entity_type(self) -> Callable[ - [entity_type.GetEntityTypeRequest], - Awaitable[entity_type.EntityType]]: - r"""Return a callable for the get entity type method over gRPC. - - Retrieves the specified entity type. - - Returns: - Callable[[~.GetEntityTypeRequest], - Awaitable[~.EntityType]]: - 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_entity_type' not in self._stubs: - self._stubs['get_entity_type'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.EntityTypes/GetEntityType', - request_serializer=entity_type.GetEntityTypeRequest.serialize, - response_deserializer=entity_type.EntityType.deserialize, - ) - return self._stubs['get_entity_type'] - - @property - def create_entity_type(self) -> Callable[ - [gcdc_entity_type.CreateEntityTypeRequest], - Awaitable[gcdc_entity_type.EntityType]]: - r"""Return a callable for the create entity type method over gRPC. - - Creates an entity type in the specified agent. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.CreateEntityTypeRequest], - Awaitable[~.EntityType]]: - 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_entity_type' not in self._stubs: - self._stubs['create_entity_type'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.EntityTypes/CreateEntityType', - request_serializer=gcdc_entity_type.CreateEntityTypeRequest.serialize, - response_deserializer=gcdc_entity_type.EntityType.deserialize, - ) - return self._stubs['create_entity_type'] - - @property - def update_entity_type(self) -> Callable[ - [gcdc_entity_type.UpdateEntityTypeRequest], - Awaitable[gcdc_entity_type.EntityType]]: - r"""Return a callable for the update entity type method over gRPC. - - Updates the specified entity type. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.UpdateEntityTypeRequest], - Awaitable[~.EntityType]]: - 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_entity_type' not in self._stubs: - self._stubs['update_entity_type'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.EntityTypes/UpdateEntityType', - request_serializer=gcdc_entity_type.UpdateEntityTypeRequest.serialize, - response_deserializer=gcdc_entity_type.EntityType.deserialize, - ) - return self._stubs['update_entity_type'] - - @property - def delete_entity_type(self) -> Callable[ - [entity_type.DeleteEntityTypeRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete entity type method over gRPC. - - Deletes the specified entity type. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.DeleteEntityTypeRequest], - 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_entity_type' not in self._stubs: - self._stubs['delete_entity_type'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.EntityTypes/DeleteEntityType', - request_serializer=entity_type.DeleteEntityTypeRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_entity_type'] - - 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"] - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - -__all__ = ( - 'EntityTypesGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/transports/rest.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/transports/rest.py deleted file mode 100644 index 48834961..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/entity_types/transports/rest.py +++ /dev/null @@ -1,1271 +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.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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.dialogflowcx_v3.types import entity_type -from google.cloud.dialogflowcx_v3.types import entity_type as gcdc_entity_type -from google.protobuf import empty_pb2 # type: ignore - -from .base import EntityTypesTransport, 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 EntityTypesRestInterceptor: - """Interceptor for EntityTypes. - - 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 EntityTypesRestTransport. - - .. code-block:: python - class MyCustomEntityTypesInterceptor(EntityTypesRestInterceptor): - def pre_create_entity_type(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_entity_type(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_entity_type(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_get_entity_type(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_entity_type(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_entity_types(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_entity_types(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_entity_type(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_entity_type(self, response): - logging.log(f"Received response: {response}") - return response - - transport = EntityTypesRestTransport(interceptor=MyCustomEntityTypesInterceptor()) - client = EntityTypesClient(transport=transport) - - - """ - def pre_create_entity_type(self, request: gcdc_entity_type.CreateEntityTypeRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_entity_type.CreateEntityTypeRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_entity_type - - Override in a subclass to manipulate the request or metadata - before they are sent to the EntityTypes server. - """ - return request, metadata - - def post_create_entity_type(self, response: gcdc_entity_type.EntityType) -> gcdc_entity_type.EntityType: - """Post-rpc interceptor for create_entity_type - - Override in a subclass to manipulate the response - after it is returned by the EntityTypes server but before - it is returned to user code. - """ - return response - def pre_delete_entity_type(self, request: entity_type.DeleteEntityTypeRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[entity_type.DeleteEntityTypeRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_entity_type - - Override in a subclass to manipulate the request or metadata - before they are sent to the EntityTypes server. - """ - return request, metadata - - def pre_get_entity_type(self, request: entity_type.GetEntityTypeRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[entity_type.GetEntityTypeRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_entity_type - - Override in a subclass to manipulate the request or metadata - before they are sent to the EntityTypes server. - """ - return request, metadata - - def post_get_entity_type(self, response: entity_type.EntityType) -> entity_type.EntityType: - """Post-rpc interceptor for get_entity_type - - Override in a subclass to manipulate the response - after it is returned by the EntityTypes server but before - it is returned to user code. - """ - return response - def pre_list_entity_types(self, request: entity_type.ListEntityTypesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[entity_type.ListEntityTypesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_entity_types - - Override in a subclass to manipulate the request or metadata - before they are sent to the EntityTypes server. - """ - return request, metadata - - def post_list_entity_types(self, response: entity_type.ListEntityTypesResponse) -> entity_type.ListEntityTypesResponse: - """Post-rpc interceptor for list_entity_types - - Override in a subclass to manipulate the response - after it is returned by the EntityTypes server but before - it is returned to user code. - """ - return response - def pre_update_entity_type(self, request: gcdc_entity_type.UpdateEntityTypeRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_entity_type.UpdateEntityTypeRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_entity_type - - Override in a subclass to manipulate the request or metadata - before they are sent to the EntityTypes server. - """ - return request, metadata - - def post_update_entity_type(self, response: gcdc_entity_type.EntityType) -> gcdc_entity_type.EntityType: - """Post-rpc interceptor for update_entity_type - - Override in a subclass to manipulate the response - after it is returned by the EntityTypes server but before - it is returned to user code. - """ - return response - - def pre_get_location( - self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_location - - Override in a subclass to manipulate the request or metadata - before they are sent to the EntityTypes server. - """ - return request, metadata - - def post_get_location( - self, response: locations_pb2.Location - ) -> locations_pb2.Location: - """Post-rpc interceptor for get_location - - Override in a subclass to manipulate the response - after it is returned by the EntityTypes server but before - it is returned to user code. - """ - return response - def pre_list_locations( - self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_locations - - Override in a subclass to manipulate the request or metadata - before they are sent to the EntityTypes server. - """ - return request, metadata - - def post_list_locations( - self, response: locations_pb2.ListLocationsResponse - ) -> locations_pb2.ListLocationsResponse: - """Post-rpc interceptor for list_locations - - Override in a subclass to manipulate the response - after it is returned by the EntityTypes 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 EntityTypes 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 EntityTypes 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 EntityTypes 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 EntityTypes 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 EntityTypes 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 EntityTypes server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class EntityTypesRestStub: - _session: AuthorizedSession - _host: str - _interceptor: EntityTypesRestInterceptor - - -class EntityTypesRestTransport(EntityTypesTransport): - """REST backend transport for EntityTypes. - - Service for managing - [EntityTypes][google.cloud.dialogflow.cx.v3.EntityType]. - - 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 = 'dialogflow.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[EntityTypesRestInterceptor] = 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) - if client_cert_source_for_mtls: - self._session.configure_mtls_channel(client_cert_source_for_mtls) - self._interceptor = interceptor or EntityTypesRestInterceptor() - self._prep_wrapped_messages(client_info) - - class _CreateEntityType(EntityTypesRestStub): - def __hash__(self): - return hash("CreateEntityType") - - __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: gcdc_entity_type.CreateEntityTypeRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_entity_type.EntityType: - r"""Call the create entity type method over HTTP. - - Args: - request (~.gcdc_entity_type.CreateEntityTypeRequest): - The request object. The request message for - [EntityTypes.CreateEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.CreateEntityType]. - 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: - ~.gcdc_entity_type.EntityType: - Entities are extracted from user input and represent - parameters that are meaningful to your application. For - example, a date range, a proper name such as a - geographic location or landmark, and so on. Entities - represent actionable data for your application. - - When you define an entity, you can also include synonyms - that all map to that entity. For example, "soft drink", - "soda", "pop", and so on. - - There are three types of entities: - - - **System** - entities that are defined by the - Dialogflow API for common data types such as date, - time, currency, and so on. A system entity is - represented by the ``EntityType`` type. - - - **Custom** - entities that are defined by you that - represent actionable data that is meaningful to your - application. For example, you could define a - ``pizza.sauce`` entity for red or white pizza sauce, - a ``pizza.cheese`` entity for the different types of - cheese on a pizza, a ``pizza.topping`` entity for - different toppings, and so on. A custom entity is - represented by the ``EntityType`` type. - - - **User** - entities that are built for an individual - user such as favorites, preferences, playlists, and - so on. A user entity is represented by the - [SessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityType] - type. - - For more information about entity types, see the - `Dialogflow - documentation `__. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*}/entityTypes', - 'body': 'entity_type', - }, - ] - request, metadata = self._interceptor.pre_create_entity_type(request, metadata) - pb_request = gcdc_entity_type.CreateEntityTypeRequest.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 = gcdc_entity_type.EntityType() - pb_resp = gcdc_entity_type.EntityType.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_entity_type(resp) - return resp - - class _DeleteEntityType(EntityTypesRestStub): - def __hash__(self): - return hash("DeleteEntityType") - - __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: entity_type.DeleteEntityTypeRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete entity type method over HTTP. - - Args: - request (~.entity_type.DeleteEntityTypeRequest): - The request object. The request message for - [EntityTypes.DeleteEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.DeleteEntityType]. - 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': '/v3/{name=projects/*/locations/*/agents/*/entityTypes/*}', - }, - ] - request, metadata = self._interceptor.pre_delete_entity_type(request, metadata) - pb_request = entity_type.DeleteEntityTypeRequest.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 _GetEntityType(EntityTypesRestStub): - def __hash__(self): - return hash("GetEntityType") - - __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: entity_type.GetEntityTypeRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> entity_type.EntityType: - r"""Call the get entity type method over HTTP. - - Args: - request (~.entity_type.GetEntityTypeRequest): - The request object. The request message for - [EntityTypes.GetEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.GetEntityType]. - 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: - ~.entity_type.EntityType: - Entities are extracted from user input and represent - parameters that are meaningful to your application. For - example, a date range, a proper name such as a - geographic location or landmark, and so on. Entities - represent actionable data for your application. - - When you define an entity, you can also include synonyms - that all map to that entity. For example, "soft drink", - "soda", "pop", and so on. - - There are three types of entities: - - - **System** - entities that are defined by the - Dialogflow API for common data types such as date, - time, currency, and so on. A system entity is - represented by the ``EntityType`` type. - - - **Custom** - entities that are defined by you that - represent actionable data that is meaningful to your - application. For example, you could define a - ``pizza.sauce`` entity for red or white pizza sauce, - a ``pizza.cheese`` entity for the different types of - cheese on a pizza, a ``pizza.topping`` entity for - different toppings, and so on. A custom entity is - represented by the ``EntityType`` type. - - - **User** - entities that are built for an individual - user such as favorites, preferences, playlists, and - so on. A user entity is represented by the - [SessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityType] - type. - - For more information about entity types, see the - `Dialogflow - documentation `__. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/entityTypes/*}', - }, - ] - request, metadata = self._interceptor.pre_get_entity_type(request, metadata) - pb_request = entity_type.GetEntityTypeRequest.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 = entity_type.EntityType() - pb_resp = entity_type.EntityType.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_entity_type(resp) - return resp - - class _ListEntityTypes(EntityTypesRestStub): - def __hash__(self): - return hash("ListEntityTypes") - - __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: entity_type.ListEntityTypesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> entity_type.ListEntityTypesResponse: - r"""Call the list entity types method over HTTP. - - Args: - request (~.entity_type.ListEntityTypesRequest): - The request object. The request message for - [EntityTypes.ListEntityTypes][google.cloud.dialogflow.cx.v3.EntityTypes.ListEntityTypes]. - 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: - ~.entity_type.ListEntityTypesResponse: - The response message for - [EntityTypes.ListEntityTypes][google.cloud.dialogflow.cx.v3.EntityTypes.ListEntityTypes]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*}/entityTypes', - }, - ] - request, metadata = self._interceptor.pre_list_entity_types(request, metadata) - pb_request = entity_type.ListEntityTypesRequest.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 = entity_type.ListEntityTypesResponse() - pb_resp = entity_type.ListEntityTypesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_entity_types(resp) - return resp - - class _UpdateEntityType(EntityTypesRestStub): - def __hash__(self): - return hash("UpdateEntityType") - - __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: gcdc_entity_type.UpdateEntityTypeRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_entity_type.EntityType: - r"""Call the update entity type method over HTTP. - - Args: - request (~.gcdc_entity_type.UpdateEntityTypeRequest): - The request object. The request message for - [EntityTypes.UpdateEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.UpdateEntityType]. - 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: - ~.gcdc_entity_type.EntityType: - Entities are extracted from user input and represent - parameters that are meaningful to your application. For - example, a date range, a proper name such as a - geographic location or landmark, and so on. Entities - represent actionable data for your application. - - When you define an entity, you can also include synonyms - that all map to that entity. For example, "soft drink", - "soda", "pop", and so on. - - There are three types of entities: - - - **System** - entities that are defined by the - Dialogflow API for common data types such as date, - time, currency, and so on. A system entity is - represented by the ``EntityType`` type. - - - **Custom** - entities that are defined by you that - represent actionable data that is meaningful to your - application. For example, you could define a - ``pizza.sauce`` entity for red or white pizza sauce, - a ``pizza.cheese`` entity for the different types of - cheese on a pizza, a ``pizza.topping`` entity for - different toppings, and so on. A custom entity is - represented by the ``EntityType`` type. - - - **User** - entities that are built for an individual - user such as favorites, preferences, playlists, and - so on. A user entity is represented by the - [SessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityType] - type. - - For more information about entity types, see the - `Dialogflow - documentation `__. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v3/{entity_type.name=projects/*/locations/*/agents/*/entityTypes/*}', - 'body': 'entity_type', - }, - ] - request, metadata = self._interceptor.pre_update_entity_type(request, metadata) - pb_request = gcdc_entity_type.UpdateEntityTypeRequest.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 = gcdc_entity_type.EntityType() - pb_resp = gcdc_entity_type.EntityType.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_entity_type(resp) - return resp - - @property - def create_entity_type(self) -> Callable[ - [gcdc_entity_type.CreateEntityTypeRequest], - gcdc_entity_type.EntityType]: - # 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._CreateEntityType(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_entity_type(self) -> Callable[ - [entity_type.DeleteEntityTypeRequest], - 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._DeleteEntityType(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_entity_type(self) -> Callable[ - [entity_type.GetEntityTypeRequest], - entity_type.EntityType]: - # 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._GetEntityType(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_entity_types(self) -> Callable[ - [entity_type.ListEntityTypesRequest], - entity_type.ListEntityTypesResponse]: - # 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._ListEntityTypes(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_entity_type(self) -> Callable[ - [gcdc_entity_type.UpdateEntityTypeRequest], - gcdc_entity_type.EntityType]: - # 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._UpdateEntityType(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_location(self): - return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore - - class _GetLocation(EntityTypesRestStub): - def __call__(self, - request: locations_pb2.GetLocationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.Location: - - r"""Call the get location method over HTTP. - - Args: - request (locations_pb2.GetLocationRequest): - The request object for GetLocation 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: - locations_pb2.Location: Response from GetLocation method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*}', - }, - ] - - request, metadata = self._interceptor.pre_get_location(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 = locations_pb2.Location() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_get_location(resp) - return resp - - @property - def list_locations(self): - return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore - - class _ListLocations(EntityTypesRestStub): - def __call__(self, - request: locations_pb2.ListLocationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.ListLocationsResponse: - - r"""Call the list locations method over HTTP. - - Args: - request (locations_pb2.ListLocationsRequest): - The request object for ListLocations 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: - locations_pb2.ListLocationsResponse: Response from ListLocations method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*}/locations', - }, - ] - - request, metadata = self._interceptor.pre_list_locations(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 = locations_pb2.ListLocationsResponse() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_list_locations(resp) - return resp - - @property - def cancel_operation(self): - return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore - - class _CancelOperation(EntityTypesRestStub): - 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': '/v3/{name=projects/*/operations/*}:cancel', - }, -{ - 'method': 'post', - 'uri': '/v3/{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(EntityTypesRestStub): - 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': '/v3/{name=projects/*/operations/*}', - }, -{ - 'method': 'get', - 'uri': '/v3/{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(EntityTypesRestStub): - 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': '/v3/{name=projects/*}/operations', - }, -{ - 'method': 'get', - 'uri': '/v3/{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__=( - 'EntityTypesRestTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/__init__.py deleted file mode 100644 index 10d18f32..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/__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 EnvironmentsClient -from .async_client import EnvironmentsAsyncClient - -__all__ = ( - 'EnvironmentsClient', - 'EnvironmentsAsyncClient', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/async_client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/async_client.py deleted file mode 100644 index 98589336..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/async_client.py +++ /dev/null @@ -1,1542 +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.dialogflowcx_v3 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.dialogflowcx_v3.services.environments import pagers -from google.cloud.dialogflowcx_v3.types import environment -from google.cloud.dialogflowcx_v3.types import environment as gcdc_environment -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import struct_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import EnvironmentsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import EnvironmentsGrpcAsyncIOTransport -from .client import EnvironmentsClient - - -class EnvironmentsAsyncClient: - """Service for managing - [Environments][google.cloud.dialogflow.cx.v3.Environment]. - """ - - _client: EnvironmentsClient - - DEFAULT_ENDPOINT = EnvironmentsClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = EnvironmentsClient.DEFAULT_MTLS_ENDPOINT - - continuous_test_result_path = staticmethod(EnvironmentsClient.continuous_test_result_path) - parse_continuous_test_result_path = staticmethod(EnvironmentsClient.parse_continuous_test_result_path) - environment_path = staticmethod(EnvironmentsClient.environment_path) - parse_environment_path = staticmethod(EnvironmentsClient.parse_environment_path) - service_path = staticmethod(EnvironmentsClient.service_path) - parse_service_path = staticmethod(EnvironmentsClient.parse_service_path) - test_case_path = staticmethod(EnvironmentsClient.test_case_path) - parse_test_case_path = staticmethod(EnvironmentsClient.parse_test_case_path) - test_case_result_path = staticmethod(EnvironmentsClient.test_case_result_path) - parse_test_case_result_path = staticmethod(EnvironmentsClient.parse_test_case_result_path) - version_path = staticmethod(EnvironmentsClient.version_path) - parse_version_path = staticmethod(EnvironmentsClient.parse_version_path) - webhook_path = staticmethod(EnvironmentsClient.webhook_path) - parse_webhook_path = staticmethod(EnvironmentsClient.parse_webhook_path) - common_billing_account_path = staticmethod(EnvironmentsClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(EnvironmentsClient.parse_common_billing_account_path) - common_folder_path = staticmethod(EnvironmentsClient.common_folder_path) - parse_common_folder_path = staticmethod(EnvironmentsClient.parse_common_folder_path) - common_organization_path = staticmethod(EnvironmentsClient.common_organization_path) - parse_common_organization_path = staticmethod(EnvironmentsClient.parse_common_organization_path) - common_project_path = staticmethod(EnvironmentsClient.common_project_path) - parse_common_project_path = staticmethod(EnvironmentsClient.parse_common_project_path) - common_location_path = staticmethod(EnvironmentsClient.common_location_path) - parse_common_location_path = staticmethod(EnvironmentsClient.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: - EnvironmentsAsyncClient: The constructed client. - """ - return EnvironmentsClient.from_service_account_info.__func__(EnvironmentsAsyncClient, 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: - EnvironmentsAsyncClient: The constructed client. - """ - return EnvironmentsClient.from_service_account_file.__func__(EnvironmentsAsyncClient, 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 EnvironmentsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> EnvironmentsTransport: - """Returns the transport used by the client instance. - - Returns: - EnvironmentsTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(EnvironmentsClient).get_transport_class, type(EnvironmentsClient)) - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, EnvironmentsTransport] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the environments 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, ~.EnvironmentsTransport]): 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 = EnvironmentsClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def list_environments(self, - request: Optional[Union[environment.ListEnvironmentsRequest, 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.ListEnvironmentsAsyncPager: - r"""Returns the list of all environments in the specified - [Agent][google.cloud.dialogflow.cx.v3.Agent]. - - .. 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 dialogflowcx_v3 - - async def sample_list_environments(): - # Create a client - client = dialogflowcx_v3.EnvironmentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListEnvironmentsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_environments(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ListEnvironmentsRequest, dict]]): - The request object. The request message for - [Environments.ListEnvironments][google.cloud.dialogflow.cx.v3.Environments.ListEnvironments]. - parent (:class:`str`): - Required. The - [Agent][google.cloud.dialogflow.cx.v3.Agent] to list all - environments for. Format: - ``projects//locations//agents/``. - - 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.dialogflowcx_v3.services.environments.pagers.ListEnvironmentsAsyncPager: - The response message for - [Environments.ListEnvironments][google.cloud.dialogflow.cx.v3.Environments.ListEnvironments]. - - 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 = environment.ListEnvironmentsRequest(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_environments, - 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.ListEnvironmentsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_environment(self, - request: Optional[Union[environment.GetEnvironmentRequest, 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]] = (), - ) -> environment.Environment: - r"""Retrieves the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - .. 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 dialogflowcx_v3 - - async def sample_get_environment(): - # Create a client - client = dialogflowcx_v3.EnvironmentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetEnvironmentRequest( - name="name_value", - ) - - # Make the request - response = await client.get_environment(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.GetEnvironmentRequest, dict]]): - The request object. The request message for - [Environments.GetEnvironment][google.cloud.dialogflow.cx.v3.Environments.GetEnvironment]. - name (:class:`str`): - Required. The name of the - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - Format: - ``projects//locations//agents//environments/``. - - 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.dialogflowcx_v3.types.Environment: - Represents an environment for an - agent. You can create multiple versions - of your agent and publish them to - separate environments. When you edit an - agent, you are editing the draft agent. - At any point, you can save the draft - agent as an agent version, which is an - immutable snapshot of your agent. When - you save the draft agent, it is - published to the default environment. - When you create agent versions, you can - publish them to custom environments. You - can create a variety of custom - environments for testing, development, - production, etc. - - """ - # 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 = environment.GetEnvironmentRequest(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_environment, - 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 create_environment(self, - request: Optional[Union[gcdc_environment.CreateEnvironmentRequest, dict]] = None, - *, - parent: Optional[str] = None, - environment: Optional[gcdc_environment.Environment] = 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 - [Environment][google.cloud.dialogflow.cx.v3.Environment] in the - specified [Agent][google.cloud.dialogflow.cx.v3.Agent]. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: - [Environment][google.cloud.dialogflow.cx.v3.Environment] - - .. 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 dialogflowcx_v3 - - async def sample_create_environment(): - # Create a client - client = dialogflowcx_v3.EnvironmentsAsyncClient() - - # Initialize request argument(s) - environment = dialogflowcx_v3.Environment() - environment.display_name = "display_name_value" - - request = dialogflowcx_v3.CreateEnvironmentRequest( - parent="parent_value", - environment=environment, - ) - - # Make the request - operation = client.create_environment(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.CreateEnvironmentRequest, dict]]): - The request object. The request message for - [Environments.CreateEnvironment][google.cloud.dialogflow.cx.v3.Environments.CreateEnvironment]. - parent (:class:`str`): - Required. The - [Agent][google.cloud.dialogflow.cx.v3.Agent] to create - an - [Environment][google.cloud.dialogflow.cx.v3.Environment] - for. Format: - ``projects//locations//agents/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - environment (:class:`google.cloud.dialogflowcx_v3.types.Environment`): - Required. The environment to create. - This corresponds to the ``environment`` 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.dialogflowcx_v3.types.Environment` Represents an environment for an agent. You can create multiple versions - of your agent and publish them to separate - environments. When you edit an agent, you are editing - the draft agent. At any point, you can save the draft - agent as an agent version, which is an immutable - snapshot of your agent. When you save the draft - agent, it is published to the default environment. - When you create agent versions, you can publish them - to custom environments. You can create a variety of - custom environments for testing, development, - production, etc. - - """ - # 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, environment]) - 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 = gcdc_environment.CreateEnvironmentRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if environment is not None: - request.environment = environment - - # 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_environment, - 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, - gcdc_environment.Environment, - metadata_type=struct_pb2.Struct, - ) - - # Done; return the response. - return response - - async def update_environment(self, - request: Optional[Union[gcdc_environment.UpdateEnvironmentRequest, dict]] = None, - *, - environment: Optional[gcdc_environment.Environment] = 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]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: - [Environment][google.cloud.dialogflow.cx.v3.Environment] - - .. 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 dialogflowcx_v3 - - async def sample_update_environment(): - # Create a client - client = dialogflowcx_v3.EnvironmentsAsyncClient() - - # Initialize request argument(s) - environment = dialogflowcx_v3.Environment() - environment.display_name = "display_name_value" - - request = dialogflowcx_v3.UpdateEnvironmentRequest( - environment=environment, - ) - - # Make the request - operation = client.update_environment(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.UpdateEnvironmentRequest, dict]]): - The request object. The request message for - [Environments.UpdateEnvironment][google.cloud.dialogflow.cx.v3.Environments.UpdateEnvironment]. - environment (:class:`google.cloud.dialogflowcx_v3.types.Environment`): - Required. The environment to update. - This corresponds to the ``environment`` 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 mask to control which - fields get 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.dialogflowcx_v3.types.Environment` Represents an environment for an agent. You can create multiple versions - of your agent and publish them to separate - environments. When you edit an agent, you are editing - the draft agent. At any point, you can save the draft - agent as an agent version, which is an immutable - snapshot of your agent. When you save the draft - agent, it is published to the default environment. - When you create agent versions, you can publish them - to custom environments. You can create a variety of - custom environments for testing, development, - production, etc. - - """ - # 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([environment, 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 = gcdc_environment.UpdateEnvironmentRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if environment is not None: - request.environment = environment - 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_environment, - 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(( - ("environment.name", request.environment.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, - gcdc_environment.Environment, - metadata_type=struct_pb2.Struct, - ) - - # Done; return the response. - return response - - async def delete_environment(self, - request: Optional[Union[environment.DeleteEnvironmentRequest, 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 the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - .. 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 dialogflowcx_v3 - - async def sample_delete_environment(): - # Create a client - client = dialogflowcx_v3.EnvironmentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteEnvironmentRequest( - name="name_value", - ) - - # Make the request - await client.delete_environment(request=request) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.DeleteEnvironmentRequest, dict]]): - The request object. The request message for - [Environments.DeleteEnvironment][google.cloud.dialogflow.cx.v3.Environments.DeleteEnvironment]. - name (:class:`str`): - Required. The name of the - [Environment][google.cloud.dialogflow.cx.v3.Environment] - to delete. Format: - ``projects//locations//agents//environments/``. - - 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 = environment.DeleteEnvironmentRequest(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_environment, - 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 lookup_environment_history(self, - request: Optional[Union[environment.LookupEnvironmentHistoryRequest, 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]] = (), - ) -> pagers.LookupEnvironmentHistoryAsyncPager: - r"""Looks up the history of the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - .. 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 dialogflowcx_v3 - - async def sample_lookup_environment_history(): - # Create a client - client = dialogflowcx_v3.EnvironmentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.LookupEnvironmentHistoryRequest( - name="name_value", - ) - - # Make the request - page_result = client.lookup_environment_history(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.LookupEnvironmentHistoryRequest, dict]]): - The request object. The request message for - [Environments.LookupEnvironmentHistory][google.cloud.dialogflow.cx.v3.Environments.LookupEnvironmentHistory]. - name (:class:`str`): - Required. Resource name of the environment to look up - the history for. Format: - ``projects//locations//agents//environments/``. - - 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.dialogflowcx_v3.services.environments.pagers.LookupEnvironmentHistoryAsyncPager: - The response message for - [Environments.LookupEnvironmentHistory][google.cloud.dialogflow.cx.v3.Environments.LookupEnvironmentHistory]. - - 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([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 = environment.LookupEnvironmentHistoryRequest(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.lookup_environment_history, - 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, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.LookupEnvironmentHistoryAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def run_continuous_test(self, - request: Optional[Union[environment.RunContinuousTestRequest, 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"""Kicks off a continuous test under the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [RunContinuousTestMetadata][google.cloud.dialogflow.cx.v3.RunContinuousTestMetadata] - - ``response``: - [RunContinuousTestResponse][google.cloud.dialogflow.cx.v3.RunContinuousTestResponse] - - .. 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 dialogflowcx_v3 - - async def sample_run_continuous_test(): - # Create a client - client = dialogflowcx_v3.EnvironmentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.RunContinuousTestRequest( - environment="environment_value", - ) - - # Make the request - operation = client.run_continuous_test(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.RunContinuousTestRequest, dict]]): - The request object. The request message for - [Environments.RunContinuousTest][google.cloud.dialogflow.cx.v3.Environments.RunContinuousTest]. - 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.dialogflowcx_v3.types.RunContinuousTestResponse` The response message for - [Environments.RunContinuousTest][google.cloud.dialogflow.cx.v3.Environments.RunContinuousTest]. - - """ - # Create or coerce a protobuf request object. - request = environment.RunContinuousTestRequest(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.run_continuous_test, - 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(( - ("environment", request.environment), - )), - ) - - # 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, - environment.RunContinuousTestResponse, - metadata_type=environment.RunContinuousTestMetadata, - ) - - # Done; return the response. - return response - - async def list_continuous_test_results(self, - request: Optional[Union[environment.ListContinuousTestResultsRequest, 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.ListContinuousTestResultsAsyncPager: - r"""Fetches a list of continuous test results for a given - environment. - - .. 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 dialogflowcx_v3 - - async def sample_list_continuous_test_results(): - # Create a client - client = dialogflowcx_v3.EnvironmentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListContinuousTestResultsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_continuous_test_results(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ListContinuousTestResultsRequest, dict]]): - The request object. The request message for - [Environments.ListContinuousTestResults][google.cloud.dialogflow.cx.v3.Environments.ListContinuousTestResults]. - parent (:class:`str`): - Required. The environment to list results for. Format: - ``projects//locations//agents// environments/``. - - 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.dialogflowcx_v3.services.environments.pagers.ListContinuousTestResultsAsyncPager: - The response message for - [Environments.ListTestCaseResults][]. - - 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 = environment.ListContinuousTestResultsRequest(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_continuous_test_results, - 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.ListContinuousTestResultsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def deploy_flow(self, - request: Optional[Union[environment.DeployFlowRequest, 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"""Deploys a flow to the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [DeployFlowMetadata][google.cloud.dialogflow.cx.v3.DeployFlowMetadata] - - ``response``: - [DeployFlowResponse][google.cloud.dialogflow.cx.v3.DeployFlowResponse] - - .. 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 dialogflowcx_v3 - - async def sample_deploy_flow(): - # Create a client - client = dialogflowcx_v3.EnvironmentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeployFlowRequest( - environment="environment_value", - flow_version="flow_version_value", - ) - - # Make the request - operation = client.deploy_flow(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.DeployFlowRequest, dict]]): - The request object. The request message for - [Environments.DeployFlow][google.cloud.dialogflow.cx.v3.Environments.DeployFlow]. - 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.dialogflowcx_v3.types.DeployFlowResponse` The response message for - [Environments.DeployFlow][google.cloud.dialogflow.cx.v3.Environments.DeployFlow]. - - """ - # Create or coerce a protobuf request object. - request = environment.DeployFlowRequest(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.deploy_flow, - 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(( - ("environment", request.environment), - )), - ) - - # 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, - environment.DeployFlowResponse, - metadata_type=environment.DeployFlowMetadata, - ) - - # Done; return the response. - return response - - 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 get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**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_location, - 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_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**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_locations, - 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 __aenter__(self) -> "EnvironmentsAsyncClient": - 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__ = ( - "EnvironmentsAsyncClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/client.py deleted file mode 100644 index 65b86c2f..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/client.py +++ /dev/null @@ -1,1797 +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.dialogflowcx_v3 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.dialogflowcx_v3.services.environments import pagers -from google.cloud.dialogflowcx_v3.types import environment -from google.cloud.dialogflowcx_v3.types import environment as gcdc_environment -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import struct_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import EnvironmentsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import EnvironmentsGrpcTransport -from .transports.grpc_asyncio import EnvironmentsGrpcAsyncIOTransport -from .transports.rest import EnvironmentsRestTransport - - -class EnvironmentsClientMeta(type): - """Metaclass for the Environments 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[EnvironmentsTransport]] - _transport_registry["grpc"] = EnvironmentsGrpcTransport - _transport_registry["grpc_asyncio"] = EnvironmentsGrpcAsyncIOTransport - _transport_registry["rest"] = EnvironmentsRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[EnvironmentsTransport]: - """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 EnvironmentsClient(metaclass=EnvironmentsClientMeta): - """Service for managing - [Environments][google.cloud.dialogflow.cx.v3.Environment]. - """ - - @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 = "dialogflow.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: - EnvironmentsClient: 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: - EnvironmentsClient: 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) -> EnvironmentsTransport: - """Returns the transport used by the client instance. - - Returns: - EnvironmentsTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def continuous_test_result_path(project: str,location: str,agent: str,environment: str,continuous_test_result: str,) -> str: - """Returns a fully-qualified continuous_test_result string.""" - return "projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/continuousTestResults/{continuous_test_result}".format(project=project, location=location, agent=agent, environment=environment, continuous_test_result=continuous_test_result, ) - - @staticmethod - def parse_continuous_test_result_path(path: str) -> Dict[str,str]: - """Parses a continuous_test_result path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/environments/(?P.+?)/continuousTestResults/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def environment_path(project: str,location: str,agent: str,environment: str,) -> str: - """Returns a fully-qualified environment string.""" - return "projects/{project}/locations/{location}/agents/{agent}/environments/{environment}".format(project=project, location=location, agent=agent, environment=environment, ) - - @staticmethod - def parse_environment_path(path: str) -> Dict[str,str]: - """Parses a environment path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/environments/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def service_path(project: str,location: str,namespace: str,service: str,) -> str: - """Returns a fully-qualified service string.""" - return "projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}".format(project=project, location=location, namespace=namespace, service=service, ) - - @staticmethod - def parse_service_path(path: str) -> Dict[str,str]: - """Parses a service path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/namespaces/(?P.+?)/services/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def test_case_path(project: str,location: str,agent: str,test_case: str,) -> str: - """Returns a fully-qualified test_case string.""" - return "projects/{project}/locations/{location}/agents/{agent}/testCases/{test_case}".format(project=project, location=location, agent=agent, test_case=test_case, ) - - @staticmethod - def parse_test_case_path(path: str) -> Dict[str,str]: - """Parses a test_case path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/testCases/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def test_case_result_path(project: str,location: str,agent: str,test_case: str,result: str,) -> str: - """Returns a fully-qualified test_case_result string.""" - return "projects/{project}/locations/{location}/agents/{agent}/testCases/{test_case}/results/{result}".format(project=project, location=location, agent=agent, test_case=test_case, result=result, ) - - @staticmethod - def parse_test_case_result_path(path: str) -> Dict[str,str]: - """Parses a test_case_result path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/testCases/(?P.+?)/results/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def version_path(project: str,location: str,agent: str,flow: str,version: str,) -> str: - """Returns a fully-qualified version string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version}".format(project=project, location=location, agent=agent, flow=flow, version=version, ) - - @staticmethod - def parse_version_path(path: str) -> Dict[str,str]: - """Parses a version path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)/versions/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def webhook_path(project: str,location: str,agent: str,webhook: str,) -> str: - """Returns a fully-qualified webhook string.""" - return "projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}".format(project=project, location=location, agent=agent, webhook=webhook, ) - - @staticmethod - def parse_webhook_path(path: str) -> Dict[str,str]: - """Parses a webhook path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/webhooks/(?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, EnvironmentsTransport]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the environments 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, EnvironmentsTransport]): 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, EnvironmentsTransport): - # transport is a EnvironmentsTransport 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 list_environments(self, - request: Optional[Union[environment.ListEnvironmentsRequest, 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.ListEnvironmentsPager: - r"""Returns the list of all environments in the specified - [Agent][google.cloud.dialogflow.cx.v3.Agent]. - - .. 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 dialogflowcx_v3 - - def sample_list_environments(): - # Create a client - client = dialogflowcx_v3.EnvironmentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListEnvironmentsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_environments(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ListEnvironmentsRequest, dict]): - The request object. The request message for - [Environments.ListEnvironments][google.cloud.dialogflow.cx.v3.Environments.ListEnvironments]. - parent (str): - Required. The - [Agent][google.cloud.dialogflow.cx.v3.Agent] to list all - environments for. Format: - ``projects//locations//agents/``. - - 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.dialogflowcx_v3.services.environments.pagers.ListEnvironmentsPager: - The response message for - [Environments.ListEnvironments][google.cloud.dialogflow.cx.v3.Environments.ListEnvironments]. - - 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 environment.ListEnvironmentsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, environment.ListEnvironmentsRequest): - request = environment.ListEnvironmentsRequest(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_environments] - - # 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.ListEnvironmentsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_environment(self, - request: Optional[Union[environment.GetEnvironmentRequest, 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]] = (), - ) -> environment.Environment: - r"""Retrieves the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - .. 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 dialogflowcx_v3 - - def sample_get_environment(): - # Create a client - client = dialogflowcx_v3.EnvironmentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetEnvironmentRequest( - name="name_value", - ) - - # Make the request - response = client.get_environment(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.GetEnvironmentRequest, dict]): - The request object. The request message for - [Environments.GetEnvironment][google.cloud.dialogflow.cx.v3.Environments.GetEnvironment]. - name (str): - Required. The name of the - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - Format: - ``projects//locations//agents//environments/``. - - 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.dialogflowcx_v3.types.Environment: - Represents an environment for an - agent. You can create multiple versions - of your agent and publish them to - separate environments. When you edit an - agent, you are editing the draft agent. - At any point, you can save the draft - agent as an agent version, which is an - immutable snapshot of your agent. When - you save the draft agent, it is - published to the default environment. - When you create agent versions, you can - publish them to custom environments. You - can create a variety of custom - environments for testing, development, - production, etc. - - """ - # 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 environment.GetEnvironmentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, environment.GetEnvironmentRequest): - request = environment.GetEnvironmentRequest(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_environment] - - # 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 create_environment(self, - request: Optional[Union[gcdc_environment.CreateEnvironmentRequest, dict]] = None, - *, - parent: Optional[str] = None, - environment: Optional[gcdc_environment.Environment] = 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 - [Environment][google.cloud.dialogflow.cx.v3.Environment] in the - specified [Agent][google.cloud.dialogflow.cx.v3.Agent]. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: - [Environment][google.cloud.dialogflow.cx.v3.Environment] - - .. 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 dialogflowcx_v3 - - def sample_create_environment(): - # Create a client - client = dialogflowcx_v3.EnvironmentsClient() - - # Initialize request argument(s) - environment = dialogflowcx_v3.Environment() - environment.display_name = "display_name_value" - - request = dialogflowcx_v3.CreateEnvironmentRequest( - parent="parent_value", - environment=environment, - ) - - # Make the request - operation = client.create_environment(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.CreateEnvironmentRequest, dict]): - The request object. The request message for - [Environments.CreateEnvironment][google.cloud.dialogflow.cx.v3.Environments.CreateEnvironment]. - parent (str): - Required. The - [Agent][google.cloud.dialogflow.cx.v3.Agent] to create - an - [Environment][google.cloud.dialogflow.cx.v3.Environment] - for. Format: - ``projects//locations//agents/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - environment (google.cloud.dialogflowcx_v3.types.Environment): - Required. The environment to create. - This corresponds to the ``environment`` 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.dialogflowcx_v3.types.Environment` Represents an environment for an agent. You can create multiple versions - of your agent and publish them to separate - environments. When you edit an agent, you are editing - the draft agent. At any point, you can save the draft - agent as an agent version, which is an immutable - snapshot of your agent. When you save the draft - agent, it is published to the default environment. - When you create agent versions, you can publish them - to custom environments. You can create a variety of - custom environments for testing, development, - production, etc. - - """ - # 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, environment]) - 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 gcdc_environment.CreateEnvironmentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_environment.CreateEnvironmentRequest): - request = gcdc_environment.CreateEnvironmentRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if environment is not None: - request.environment = environment - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_environment] - - # 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, - gcdc_environment.Environment, - metadata_type=struct_pb2.Struct, - ) - - # Done; return the response. - return response - - def update_environment(self, - request: Optional[Union[gcdc_environment.UpdateEnvironmentRequest, dict]] = None, - *, - environment: Optional[gcdc_environment.Environment] = 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]] = (), - ) -> operation.Operation: - r"""Updates the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: - [Environment][google.cloud.dialogflow.cx.v3.Environment] - - .. 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 dialogflowcx_v3 - - def sample_update_environment(): - # Create a client - client = dialogflowcx_v3.EnvironmentsClient() - - # Initialize request argument(s) - environment = dialogflowcx_v3.Environment() - environment.display_name = "display_name_value" - - request = dialogflowcx_v3.UpdateEnvironmentRequest( - environment=environment, - ) - - # Make the request - operation = client.update_environment(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.UpdateEnvironmentRequest, dict]): - The request object. The request message for - [Environments.UpdateEnvironment][google.cloud.dialogflow.cx.v3.Environments.UpdateEnvironment]. - environment (google.cloud.dialogflowcx_v3.types.Environment): - Required. The environment to update. - This corresponds to the ``environment`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The mask to control which - fields get 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.dialogflowcx_v3.types.Environment` Represents an environment for an agent. You can create multiple versions - of your agent and publish them to separate - environments. When you edit an agent, you are editing - the draft agent. At any point, you can save the draft - agent as an agent version, which is an immutable - snapshot of your agent. When you save the draft - agent, it is published to the default environment. - When you create agent versions, you can publish them - to custom environments. You can create a variety of - custom environments for testing, development, - production, etc. - - """ - # 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([environment, 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 gcdc_environment.UpdateEnvironmentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_environment.UpdateEnvironmentRequest): - request = gcdc_environment.UpdateEnvironmentRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if environment is not None: - request.environment = environment - 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_environment] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("environment.name", request.environment.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, - gcdc_environment.Environment, - metadata_type=struct_pb2.Struct, - ) - - # Done; return the response. - return response - - def delete_environment(self, - request: Optional[Union[environment.DeleteEnvironmentRequest, 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 the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - .. 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 dialogflowcx_v3 - - def sample_delete_environment(): - # Create a client - client = dialogflowcx_v3.EnvironmentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteEnvironmentRequest( - name="name_value", - ) - - # Make the request - client.delete_environment(request=request) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.DeleteEnvironmentRequest, dict]): - The request object. The request message for - [Environments.DeleteEnvironment][google.cloud.dialogflow.cx.v3.Environments.DeleteEnvironment]. - name (str): - Required. The name of the - [Environment][google.cloud.dialogflow.cx.v3.Environment] - to delete. Format: - ``projects//locations//agents//environments/``. - - 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 environment.DeleteEnvironmentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, environment.DeleteEnvironmentRequest): - request = environment.DeleteEnvironmentRequest(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_environment] - - # 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 lookup_environment_history(self, - request: Optional[Union[environment.LookupEnvironmentHistoryRequest, 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]] = (), - ) -> pagers.LookupEnvironmentHistoryPager: - r"""Looks up the history of the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - .. 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 dialogflowcx_v3 - - def sample_lookup_environment_history(): - # Create a client - client = dialogflowcx_v3.EnvironmentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.LookupEnvironmentHistoryRequest( - name="name_value", - ) - - # Make the request - page_result = client.lookup_environment_history(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.LookupEnvironmentHistoryRequest, dict]): - The request object. The request message for - [Environments.LookupEnvironmentHistory][google.cloud.dialogflow.cx.v3.Environments.LookupEnvironmentHistory]. - name (str): - Required. Resource name of the environment to look up - the history for. Format: - ``projects//locations//agents//environments/``. - - 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.dialogflowcx_v3.services.environments.pagers.LookupEnvironmentHistoryPager: - The response message for - [Environments.LookupEnvironmentHistory][google.cloud.dialogflow.cx.v3.Environments.LookupEnvironmentHistory]. - - 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([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 environment.LookupEnvironmentHistoryRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, environment.LookupEnvironmentHistoryRequest): - request = environment.LookupEnvironmentHistoryRequest(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.lookup_environment_history] - - # 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, - ) - - # This method is paged; wrap the response in a pager, which provides - # an `__iter__` convenience method. - response = pagers.LookupEnvironmentHistoryPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def run_continuous_test(self, - request: Optional[Union[environment.RunContinuousTestRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Kicks off a continuous test under the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [RunContinuousTestMetadata][google.cloud.dialogflow.cx.v3.RunContinuousTestMetadata] - - ``response``: - [RunContinuousTestResponse][google.cloud.dialogflow.cx.v3.RunContinuousTestResponse] - - .. 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 dialogflowcx_v3 - - def sample_run_continuous_test(): - # Create a client - client = dialogflowcx_v3.EnvironmentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.RunContinuousTestRequest( - environment="environment_value", - ) - - # Make the request - operation = client.run_continuous_test(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.RunContinuousTestRequest, dict]): - The request object. The request message for - [Environments.RunContinuousTest][google.cloud.dialogflow.cx.v3.Environments.RunContinuousTest]. - 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.dialogflowcx_v3.types.RunContinuousTestResponse` The response message for - [Environments.RunContinuousTest][google.cloud.dialogflow.cx.v3.Environments.RunContinuousTest]. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a environment.RunContinuousTestRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, environment.RunContinuousTestRequest): - request = environment.RunContinuousTestRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.run_continuous_test] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("environment", request.environment), - )), - ) - - # 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, - environment.RunContinuousTestResponse, - metadata_type=environment.RunContinuousTestMetadata, - ) - - # Done; return the response. - return response - - def list_continuous_test_results(self, - request: Optional[Union[environment.ListContinuousTestResultsRequest, 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.ListContinuousTestResultsPager: - r"""Fetches a list of continuous test results for a given - environment. - - .. 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 dialogflowcx_v3 - - def sample_list_continuous_test_results(): - # Create a client - client = dialogflowcx_v3.EnvironmentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListContinuousTestResultsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_continuous_test_results(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ListContinuousTestResultsRequest, dict]): - The request object. The request message for - [Environments.ListContinuousTestResults][google.cloud.dialogflow.cx.v3.Environments.ListContinuousTestResults]. - parent (str): - Required. The environment to list results for. Format: - ``projects//locations//agents// environments/``. - - 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.dialogflowcx_v3.services.environments.pagers.ListContinuousTestResultsPager: - The response message for - [Environments.ListTestCaseResults][]. - - 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 environment.ListContinuousTestResultsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, environment.ListContinuousTestResultsRequest): - request = environment.ListContinuousTestResultsRequest(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_continuous_test_results] - - # 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.ListContinuousTestResultsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def deploy_flow(self, - request: Optional[Union[environment.DeployFlowRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Deploys a flow to the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [DeployFlowMetadata][google.cloud.dialogflow.cx.v3.DeployFlowMetadata] - - ``response``: - [DeployFlowResponse][google.cloud.dialogflow.cx.v3.DeployFlowResponse] - - .. 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 dialogflowcx_v3 - - def sample_deploy_flow(): - # Create a client - client = dialogflowcx_v3.EnvironmentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeployFlowRequest( - environment="environment_value", - flow_version="flow_version_value", - ) - - # Make the request - operation = client.deploy_flow(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.DeployFlowRequest, dict]): - The request object. The request message for - [Environments.DeployFlow][google.cloud.dialogflow.cx.v3.Environments.DeployFlow]. - 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.dialogflowcx_v3.types.DeployFlowResponse` The response message for - [Environments.DeployFlow][google.cloud.dialogflow.cx.v3.Environments.DeployFlow]. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a environment.DeployFlowRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, environment.DeployFlowRequest): - request = environment.DeployFlowRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.deploy_flow] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("environment", request.environment), - )), - ) - - # 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, - environment.DeployFlowResponse, - metadata_type=environment.DeployFlowMetadata, - ) - - # Done; return the response. - return response - - def __enter__(self) -> "EnvironmentsClient": - 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,) - - def get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.get_location, - 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 list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.list_locations, - 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 - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "EnvironmentsClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/pagers.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/pagers.py deleted file mode 100644 index f7ee786f..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/pagers.py +++ /dev/null @@ -1,381 +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.dialogflowcx_v3.types import environment - - -class ListEnvironmentsPager: - """A pager for iterating through ``list_environments`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListEnvironmentsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``environments`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListEnvironments`` requests and continue to iterate - through the ``environments`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListEnvironmentsResponse` - 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[..., environment.ListEnvironmentsResponse], - request: environment.ListEnvironmentsRequest, - response: environment.ListEnvironmentsResponse, - *, - 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.dialogflowcx_v3.types.ListEnvironmentsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListEnvironmentsResponse): - 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 = environment.ListEnvironmentsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[environment.ListEnvironmentsResponse]: - 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[environment.Environment]: - for page in self.pages: - yield from page.environments - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListEnvironmentsAsyncPager: - """A pager for iterating through ``list_environments`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListEnvironmentsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``environments`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListEnvironments`` requests and continue to iterate - through the ``environments`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListEnvironmentsResponse` - 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[environment.ListEnvironmentsResponse]], - request: environment.ListEnvironmentsRequest, - response: environment.ListEnvironmentsResponse, - *, - 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.dialogflowcx_v3.types.ListEnvironmentsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListEnvironmentsResponse): - 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 = environment.ListEnvironmentsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[environment.ListEnvironmentsResponse]: - 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[environment.Environment]: - async def async_generator(): - async for page in self.pages: - for response in page.environments: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class LookupEnvironmentHistoryPager: - """A pager for iterating through ``lookup_environment_history`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.LookupEnvironmentHistoryResponse` object, and - provides an ``__iter__`` method to iterate through its - ``environments`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``LookupEnvironmentHistory`` requests and continue to iterate - through the ``environments`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.LookupEnvironmentHistoryResponse` - 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[..., environment.LookupEnvironmentHistoryResponse], - request: environment.LookupEnvironmentHistoryRequest, - response: environment.LookupEnvironmentHistoryResponse, - *, - 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.dialogflowcx_v3.types.LookupEnvironmentHistoryRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.LookupEnvironmentHistoryResponse): - 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 = environment.LookupEnvironmentHistoryRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[environment.LookupEnvironmentHistoryResponse]: - 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[environment.Environment]: - for page in self.pages: - yield from page.environments - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class LookupEnvironmentHistoryAsyncPager: - """A pager for iterating through ``lookup_environment_history`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.LookupEnvironmentHistoryResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``environments`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``LookupEnvironmentHistory`` requests and continue to iterate - through the ``environments`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.LookupEnvironmentHistoryResponse` - 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[environment.LookupEnvironmentHistoryResponse]], - request: environment.LookupEnvironmentHistoryRequest, - response: environment.LookupEnvironmentHistoryResponse, - *, - 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.dialogflowcx_v3.types.LookupEnvironmentHistoryRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.LookupEnvironmentHistoryResponse): - 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 = environment.LookupEnvironmentHistoryRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[environment.LookupEnvironmentHistoryResponse]: - 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[environment.Environment]: - async def async_generator(): - async for page in self.pages: - for response in page.environments: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListContinuousTestResultsPager: - """A pager for iterating through ``list_continuous_test_results`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListContinuousTestResultsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``continuous_test_results`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListContinuousTestResults`` requests and continue to iterate - through the ``continuous_test_results`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListContinuousTestResultsResponse` - 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[..., environment.ListContinuousTestResultsResponse], - request: environment.ListContinuousTestResultsRequest, - response: environment.ListContinuousTestResultsResponse, - *, - 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.dialogflowcx_v3.types.ListContinuousTestResultsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListContinuousTestResultsResponse): - 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 = environment.ListContinuousTestResultsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[environment.ListContinuousTestResultsResponse]: - 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[environment.ContinuousTestResult]: - for page in self.pages: - yield from page.continuous_test_results - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListContinuousTestResultsAsyncPager: - """A pager for iterating through ``list_continuous_test_results`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListContinuousTestResultsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``continuous_test_results`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListContinuousTestResults`` requests and continue to iterate - through the ``continuous_test_results`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListContinuousTestResultsResponse` - 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[environment.ListContinuousTestResultsResponse]], - request: environment.ListContinuousTestResultsRequest, - response: environment.ListContinuousTestResultsResponse, - *, - 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.dialogflowcx_v3.types.ListContinuousTestResultsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListContinuousTestResultsResponse): - 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 = environment.ListContinuousTestResultsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[environment.ListContinuousTestResultsResponse]: - 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[environment.ContinuousTestResult]: - async def async_generator(): - async for page in self.pages: - for response in page.continuous_test_results: - 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/v3/google/cloud/dialogflowcx_v3/services/environments/transports/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/transports/__init__.py deleted file mode 100644 index 6e7dbd28..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/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 EnvironmentsTransport -from .grpc import EnvironmentsGrpcTransport -from .grpc_asyncio import EnvironmentsGrpcAsyncIOTransport -from .rest import EnvironmentsRestTransport -from .rest import EnvironmentsRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[EnvironmentsTransport]] -_transport_registry['grpc'] = EnvironmentsGrpcTransport -_transport_registry['grpc_asyncio'] = EnvironmentsGrpcAsyncIOTransport -_transport_registry['rest'] = EnvironmentsRestTransport - -__all__ = ( - 'EnvironmentsTransport', - 'EnvironmentsGrpcTransport', - 'EnvironmentsGrpcAsyncIOTransport', - 'EnvironmentsRestTransport', - 'EnvironmentsRestInterceptor', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/transports/base.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/transports/base.py deleted file mode 100644 index fc89657e..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/transports/base.py +++ /dev/null @@ -1,315 +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.dialogflowcx_v3 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.dialogflowcx_v3.types import environment -from google.cloud.dialogflowcx_v3.types import environment as gcdc_environment -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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 EnvironmentsTransport(abc.ABC): - """Abstract transport class for Environments.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/dialogflow', - ) - - DEFAULT_HOST: str = 'dialogflow.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.list_environments: gapic_v1.method.wrap_method( - self.list_environments, - default_timeout=None, - client_info=client_info, - ), - self.get_environment: gapic_v1.method.wrap_method( - self.get_environment, - default_timeout=None, - client_info=client_info, - ), - self.create_environment: gapic_v1.method.wrap_method( - self.create_environment, - default_timeout=None, - client_info=client_info, - ), - self.update_environment: gapic_v1.method.wrap_method( - self.update_environment, - default_timeout=None, - client_info=client_info, - ), - self.delete_environment: gapic_v1.method.wrap_method( - self.delete_environment, - default_timeout=None, - client_info=client_info, - ), - self.lookup_environment_history: gapic_v1.method.wrap_method( - self.lookup_environment_history, - default_timeout=None, - client_info=client_info, - ), - self.run_continuous_test: gapic_v1.method.wrap_method( - self.run_continuous_test, - default_timeout=None, - client_info=client_info, - ), - self.list_continuous_test_results: gapic_v1.method.wrap_method( - self.list_continuous_test_results, - default_timeout=None, - client_info=client_info, - ), - self.deploy_flow: gapic_v1.method.wrap_method( - self.deploy_flow, - 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 list_environments(self) -> Callable[ - [environment.ListEnvironmentsRequest], - Union[ - environment.ListEnvironmentsResponse, - Awaitable[environment.ListEnvironmentsResponse] - ]]: - raise NotImplementedError() - - @property - def get_environment(self) -> Callable[ - [environment.GetEnvironmentRequest], - Union[ - environment.Environment, - Awaitable[environment.Environment] - ]]: - raise NotImplementedError() - - @property - def create_environment(self) -> Callable[ - [gcdc_environment.CreateEnvironmentRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_environment(self) -> Callable[ - [gcdc_environment.UpdateEnvironmentRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_environment(self) -> Callable[ - [environment.DeleteEnvironmentRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def lookup_environment_history(self) -> Callable[ - [environment.LookupEnvironmentHistoryRequest], - Union[ - environment.LookupEnvironmentHistoryResponse, - Awaitable[environment.LookupEnvironmentHistoryResponse] - ]]: - raise NotImplementedError() - - @property - def run_continuous_test(self) -> Callable[ - [environment.RunContinuousTestRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_continuous_test_results(self) -> Callable[ - [environment.ListContinuousTestResultsRequest], - Union[ - environment.ListContinuousTestResultsResponse, - Awaitable[environment.ListContinuousTestResultsResponse] - ]]: - raise NotImplementedError() - - @property - def deploy_flow(self) -> Callable[ - [environment.DeployFlowRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - 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 get_location(self, - ) -> Callable[ - [locations_pb2.GetLocationRequest], - Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], - ]: - raise NotImplementedError() - - @property - def list_locations(self, - ) -> Callable[ - [locations_pb2.ListLocationsRequest], - Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'EnvironmentsTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/transports/grpc.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/transports/grpc.py deleted file mode 100644 index b1745b99..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/transports/grpc.py +++ /dev/null @@ -1,636 +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.dialogflowcx_v3.types import environment -from google.cloud.dialogflowcx_v3.types import environment as gcdc_environment -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import EnvironmentsTransport, DEFAULT_CLIENT_INFO - - -class EnvironmentsGrpcTransport(EnvironmentsTransport): - """gRPC backend transport for Environments. - - Service for managing - [Environments][google.cloud.dialogflow.cx.v3.Environment]. - - 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 = 'dialogflow.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 = 'dialogflow.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 list_environments(self) -> Callable[ - [environment.ListEnvironmentsRequest], - environment.ListEnvironmentsResponse]: - r"""Return a callable for the list environments method over gRPC. - - Returns the list of all environments in the specified - [Agent][google.cloud.dialogflow.cx.v3.Agent]. - - Returns: - Callable[[~.ListEnvironmentsRequest], - ~.ListEnvironmentsResponse]: - 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_environments' not in self._stubs: - self._stubs['list_environments'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Environments/ListEnvironments', - request_serializer=environment.ListEnvironmentsRequest.serialize, - response_deserializer=environment.ListEnvironmentsResponse.deserialize, - ) - return self._stubs['list_environments'] - - @property - def get_environment(self) -> Callable[ - [environment.GetEnvironmentRequest], - environment.Environment]: - r"""Return a callable for the get environment method over gRPC. - - Retrieves the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - Returns: - Callable[[~.GetEnvironmentRequest], - ~.Environment]: - 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_environment' not in self._stubs: - self._stubs['get_environment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Environments/GetEnvironment', - request_serializer=environment.GetEnvironmentRequest.serialize, - response_deserializer=environment.Environment.deserialize, - ) - return self._stubs['get_environment'] - - @property - def create_environment(self) -> Callable[ - [gcdc_environment.CreateEnvironmentRequest], - operations_pb2.Operation]: - r"""Return a callable for the create environment method over gRPC. - - Creates an - [Environment][google.cloud.dialogflow.cx.v3.Environment] in the - specified [Agent][google.cloud.dialogflow.cx.v3.Agent]. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: - [Environment][google.cloud.dialogflow.cx.v3.Environment] - - Returns: - Callable[[~.CreateEnvironmentRequest], - ~.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_environment' not in self._stubs: - self._stubs['create_environment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Environments/CreateEnvironment', - request_serializer=gcdc_environment.CreateEnvironmentRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_environment'] - - @property - def update_environment(self) -> Callable[ - [gcdc_environment.UpdateEnvironmentRequest], - operations_pb2.Operation]: - r"""Return a callable for the update environment method over gRPC. - - Updates the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: - [Environment][google.cloud.dialogflow.cx.v3.Environment] - - Returns: - Callable[[~.UpdateEnvironmentRequest], - ~.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 'update_environment' not in self._stubs: - self._stubs['update_environment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Environments/UpdateEnvironment', - request_serializer=gcdc_environment.UpdateEnvironmentRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_environment'] - - @property - def delete_environment(self) -> Callable[ - [environment.DeleteEnvironmentRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete environment method over gRPC. - - Deletes the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - Returns: - Callable[[~.DeleteEnvironmentRequest], - ~.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_environment' not in self._stubs: - self._stubs['delete_environment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Environments/DeleteEnvironment', - request_serializer=environment.DeleteEnvironmentRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_environment'] - - @property - def lookup_environment_history(self) -> Callable[ - [environment.LookupEnvironmentHistoryRequest], - environment.LookupEnvironmentHistoryResponse]: - r"""Return a callable for the lookup environment history method over gRPC. - - Looks up the history of the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - Returns: - Callable[[~.LookupEnvironmentHistoryRequest], - ~.LookupEnvironmentHistoryResponse]: - 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 'lookup_environment_history' not in self._stubs: - self._stubs['lookup_environment_history'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Environments/LookupEnvironmentHistory', - request_serializer=environment.LookupEnvironmentHistoryRequest.serialize, - response_deserializer=environment.LookupEnvironmentHistoryResponse.deserialize, - ) - return self._stubs['lookup_environment_history'] - - @property - def run_continuous_test(self) -> Callable[ - [environment.RunContinuousTestRequest], - operations_pb2.Operation]: - r"""Return a callable for the run continuous test method over gRPC. - - Kicks off a continuous test under the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [RunContinuousTestMetadata][google.cloud.dialogflow.cx.v3.RunContinuousTestMetadata] - - ``response``: - [RunContinuousTestResponse][google.cloud.dialogflow.cx.v3.RunContinuousTestResponse] - - Returns: - Callable[[~.RunContinuousTestRequest], - ~.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 'run_continuous_test' not in self._stubs: - self._stubs['run_continuous_test'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Environments/RunContinuousTest', - request_serializer=environment.RunContinuousTestRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['run_continuous_test'] - - @property - def list_continuous_test_results(self) -> Callable[ - [environment.ListContinuousTestResultsRequest], - environment.ListContinuousTestResultsResponse]: - r"""Return a callable for the list continuous test results method over gRPC. - - Fetches a list of continuous test results for a given - environment. - - Returns: - Callable[[~.ListContinuousTestResultsRequest], - ~.ListContinuousTestResultsResponse]: - 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_continuous_test_results' not in self._stubs: - self._stubs['list_continuous_test_results'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Environments/ListContinuousTestResults', - request_serializer=environment.ListContinuousTestResultsRequest.serialize, - response_deserializer=environment.ListContinuousTestResultsResponse.deserialize, - ) - return self._stubs['list_continuous_test_results'] - - @property - def deploy_flow(self) -> Callable[ - [environment.DeployFlowRequest], - operations_pb2.Operation]: - r"""Return a callable for the deploy flow method over gRPC. - - Deploys a flow to the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [DeployFlowMetadata][google.cloud.dialogflow.cx.v3.DeployFlowMetadata] - - ``response``: - [DeployFlowResponse][google.cloud.dialogflow.cx.v3.DeployFlowResponse] - - Returns: - Callable[[~.DeployFlowRequest], - ~.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_flow' not in self._stubs: - self._stubs['deploy_flow'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Environments/DeployFlow', - request_serializer=environment.DeployFlowRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['deploy_flow'] - - 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 list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'EnvironmentsGrpcTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/transports/grpc_asyncio.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/transports/grpc_asyncio.py deleted file mode 100644 index 2b091fc7..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/transports/grpc_asyncio.py +++ /dev/null @@ -1,635 +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.dialogflowcx_v3.types import environment -from google.cloud.dialogflowcx_v3.types import environment as gcdc_environment -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import EnvironmentsTransport, DEFAULT_CLIENT_INFO -from .grpc import EnvironmentsGrpcTransport - - -class EnvironmentsGrpcAsyncIOTransport(EnvironmentsTransport): - """gRPC AsyncIO backend transport for Environments. - - Service for managing - [Environments][google.cloud.dialogflow.cx.v3.Environment]. - - 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 = 'dialogflow.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 = 'dialogflow.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 list_environments(self) -> Callable[ - [environment.ListEnvironmentsRequest], - Awaitable[environment.ListEnvironmentsResponse]]: - r"""Return a callable for the list environments method over gRPC. - - Returns the list of all environments in the specified - [Agent][google.cloud.dialogflow.cx.v3.Agent]. - - Returns: - Callable[[~.ListEnvironmentsRequest], - Awaitable[~.ListEnvironmentsResponse]]: - 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_environments' not in self._stubs: - self._stubs['list_environments'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Environments/ListEnvironments', - request_serializer=environment.ListEnvironmentsRequest.serialize, - response_deserializer=environment.ListEnvironmentsResponse.deserialize, - ) - return self._stubs['list_environments'] - - @property - def get_environment(self) -> Callable[ - [environment.GetEnvironmentRequest], - Awaitable[environment.Environment]]: - r"""Return a callable for the get environment method over gRPC. - - Retrieves the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - Returns: - Callable[[~.GetEnvironmentRequest], - Awaitable[~.Environment]]: - 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_environment' not in self._stubs: - self._stubs['get_environment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Environments/GetEnvironment', - request_serializer=environment.GetEnvironmentRequest.serialize, - response_deserializer=environment.Environment.deserialize, - ) - return self._stubs['get_environment'] - - @property - def create_environment(self) -> Callable[ - [gcdc_environment.CreateEnvironmentRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create environment method over gRPC. - - Creates an - [Environment][google.cloud.dialogflow.cx.v3.Environment] in the - specified [Agent][google.cloud.dialogflow.cx.v3.Agent]. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: - [Environment][google.cloud.dialogflow.cx.v3.Environment] - - Returns: - Callable[[~.CreateEnvironmentRequest], - 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_environment' not in self._stubs: - self._stubs['create_environment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Environments/CreateEnvironment', - request_serializer=gcdc_environment.CreateEnvironmentRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_environment'] - - @property - def update_environment(self) -> Callable[ - [gcdc_environment.UpdateEnvironmentRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update environment method over gRPC. - - Updates the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: - [Environment][google.cloud.dialogflow.cx.v3.Environment] - - Returns: - Callable[[~.UpdateEnvironmentRequest], - 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 'update_environment' not in self._stubs: - self._stubs['update_environment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Environments/UpdateEnvironment', - request_serializer=gcdc_environment.UpdateEnvironmentRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_environment'] - - @property - def delete_environment(self) -> Callable[ - [environment.DeleteEnvironmentRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete environment method over gRPC. - - Deletes the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - Returns: - Callable[[~.DeleteEnvironmentRequest], - 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_environment' not in self._stubs: - self._stubs['delete_environment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Environments/DeleteEnvironment', - request_serializer=environment.DeleteEnvironmentRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_environment'] - - @property - def lookup_environment_history(self) -> Callable[ - [environment.LookupEnvironmentHistoryRequest], - Awaitable[environment.LookupEnvironmentHistoryResponse]]: - r"""Return a callable for the lookup environment history method over gRPC. - - Looks up the history of the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - Returns: - Callable[[~.LookupEnvironmentHistoryRequest], - Awaitable[~.LookupEnvironmentHistoryResponse]]: - 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 'lookup_environment_history' not in self._stubs: - self._stubs['lookup_environment_history'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Environments/LookupEnvironmentHistory', - request_serializer=environment.LookupEnvironmentHistoryRequest.serialize, - response_deserializer=environment.LookupEnvironmentHistoryResponse.deserialize, - ) - return self._stubs['lookup_environment_history'] - - @property - def run_continuous_test(self) -> Callable[ - [environment.RunContinuousTestRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the run continuous test method over gRPC. - - Kicks off a continuous test under the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [RunContinuousTestMetadata][google.cloud.dialogflow.cx.v3.RunContinuousTestMetadata] - - ``response``: - [RunContinuousTestResponse][google.cloud.dialogflow.cx.v3.RunContinuousTestResponse] - - Returns: - Callable[[~.RunContinuousTestRequest], - 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 'run_continuous_test' not in self._stubs: - self._stubs['run_continuous_test'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Environments/RunContinuousTest', - request_serializer=environment.RunContinuousTestRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['run_continuous_test'] - - @property - def list_continuous_test_results(self) -> Callable[ - [environment.ListContinuousTestResultsRequest], - Awaitable[environment.ListContinuousTestResultsResponse]]: - r"""Return a callable for the list continuous test results method over gRPC. - - Fetches a list of continuous test results for a given - environment. - - Returns: - Callable[[~.ListContinuousTestResultsRequest], - Awaitable[~.ListContinuousTestResultsResponse]]: - 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_continuous_test_results' not in self._stubs: - self._stubs['list_continuous_test_results'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Environments/ListContinuousTestResults', - request_serializer=environment.ListContinuousTestResultsRequest.serialize, - response_deserializer=environment.ListContinuousTestResultsResponse.deserialize, - ) - return self._stubs['list_continuous_test_results'] - - @property - def deploy_flow(self) -> Callable[ - [environment.DeployFlowRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the deploy flow method over gRPC. - - Deploys a flow to the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [DeployFlowMetadata][google.cloud.dialogflow.cx.v3.DeployFlowMetadata] - - ``response``: - [DeployFlowResponse][google.cloud.dialogflow.cx.v3.DeployFlowResponse] - - Returns: - Callable[[~.DeployFlowRequest], - 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_flow' not in self._stubs: - self._stubs['deploy_flow'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Environments/DeployFlow', - request_serializer=environment.DeployFlowRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['deploy_flow'] - - 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"] - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - -__all__ = ( - 'EnvironmentsGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/transports/rest.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/transports/rest.py deleted file mode 100644 index 5a601ebb..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/environments/transports/rest.py +++ /dev/null @@ -1,1711 +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 google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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.dialogflowcx_v3.types import environment -from google.cloud.dialogflowcx_v3.types import environment as gcdc_environment -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore - -from .base import EnvironmentsTransport, 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 EnvironmentsRestInterceptor: - """Interceptor for Environments. - - 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 EnvironmentsRestTransport. - - .. code-block:: python - class MyCustomEnvironmentsInterceptor(EnvironmentsRestInterceptor): - def pre_create_environment(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_environment(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_environment(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_deploy_flow(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_deploy_flow(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_environment(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_environment(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_continuous_test_results(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_continuous_test_results(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_environments(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_environments(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_lookup_environment_history(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_lookup_environment_history(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_run_continuous_test(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_run_continuous_test(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_environment(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_environment(self, response): - logging.log(f"Received response: {response}") - return response - - transport = EnvironmentsRestTransport(interceptor=MyCustomEnvironmentsInterceptor()) - client = EnvironmentsClient(transport=transport) - - - """ - def pre_create_environment(self, request: gcdc_environment.CreateEnvironmentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_environment.CreateEnvironmentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_environment - - Override in a subclass to manipulate the request or metadata - before they are sent to the Environments server. - """ - return request, metadata - - def post_create_environment(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for create_environment - - Override in a subclass to manipulate the response - after it is returned by the Environments server but before - it is returned to user code. - """ - return response - def pre_delete_environment(self, request: environment.DeleteEnvironmentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[environment.DeleteEnvironmentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_environment - - Override in a subclass to manipulate the request or metadata - before they are sent to the Environments server. - """ - return request, metadata - - def pre_deploy_flow(self, request: environment.DeployFlowRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[environment.DeployFlowRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for deploy_flow - - Override in a subclass to manipulate the request or metadata - before they are sent to the Environments server. - """ - return request, metadata - - def post_deploy_flow(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for deploy_flow - - Override in a subclass to manipulate the response - after it is returned by the Environments server but before - it is returned to user code. - """ - return response - def pre_get_environment(self, request: environment.GetEnvironmentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[environment.GetEnvironmentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_environment - - Override in a subclass to manipulate the request or metadata - before they are sent to the Environments server. - """ - return request, metadata - - def post_get_environment(self, response: environment.Environment) -> environment.Environment: - """Post-rpc interceptor for get_environment - - Override in a subclass to manipulate the response - after it is returned by the Environments server but before - it is returned to user code. - """ - return response - def pre_list_continuous_test_results(self, request: environment.ListContinuousTestResultsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[environment.ListContinuousTestResultsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_continuous_test_results - - Override in a subclass to manipulate the request or metadata - before they are sent to the Environments server. - """ - return request, metadata - - def post_list_continuous_test_results(self, response: environment.ListContinuousTestResultsResponse) -> environment.ListContinuousTestResultsResponse: - """Post-rpc interceptor for list_continuous_test_results - - Override in a subclass to manipulate the response - after it is returned by the Environments server but before - it is returned to user code. - """ - return response - def pre_list_environments(self, request: environment.ListEnvironmentsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[environment.ListEnvironmentsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_environments - - Override in a subclass to manipulate the request or metadata - before they are sent to the Environments server. - """ - return request, metadata - - def post_list_environments(self, response: environment.ListEnvironmentsResponse) -> environment.ListEnvironmentsResponse: - """Post-rpc interceptor for list_environments - - Override in a subclass to manipulate the response - after it is returned by the Environments server but before - it is returned to user code. - """ - return response - def pre_lookup_environment_history(self, request: environment.LookupEnvironmentHistoryRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[environment.LookupEnvironmentHistoryRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for lookup_environment_history - - Override in a subclass to manipulate the request or metadata - before they are sent to the Environments server. - """ - return request, metadata - - def post_lookup_environment_history(self, response: environment.LookupEnvironmentHistoryResponse) -> environment.LookupEnvironmentHistoryResponse: - """Post-rpc interceptor for lookup_environment_history - - Override in a subclass to manipulate the response - after it is returned by the Environments server but before - it is returned to user code. - """ - return response - def pre_run_continuous_test(self, request: environment.RunContinuousTestRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[environment.RunContinuousTestRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for run_continuous_test - - Override in a subclass to manipulate the request or metadata - before they are sent to the Environments server. - """ - return request, metadata - - def post_run_continuous_test(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for run_continuous_test - - Override in a subclass to manipulate the response - after it is returned by the Environments server but before - it is returned to user code. - """ - return response - def pre_update_environment(self, request: gcdc_environment.UpdateEnvironmentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_environment.UpdateEnvironmentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_environment - - Override in a subclass to manipulate the request or metadata - before they are sent to the Environments server. - """ - return request, metadata - - def post_update_environment(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for update_environment - - Override in a subclass to manipulate the response - after it is returned by the Environments server but before - it is returned to user code. - """ - return response - - def pre_get_location( - self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_location - - Override in a subclass to manipulate the request or metadata - before they are sent to the Environments server. - """ - return request, metadata - - def post_get_location( - self, response: locations_pb2.Location - ) -> locations_pb2.Location: - """Post-rpc interceptor for get_location - - Override in a subclass to manipulate the response - after it is returned by the Environments server but before - it is returned to user code. - """ - return response - def pre_list_locations( - self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_locations - - Override in a subclass to manipulate the request or metadata - before they are sent to the Environments server. - """ - return request, metadata - - def post_list_locations( - self, response: locations_pb2.ListLocationsResponse - ) -> locations_pb2.ListLocationsResponse: - """Post-rpc interceptor for list_locations - - Override in a subclass to manipulate the response - after it is returned by the Environments 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 Environments 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 Environments 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 Environments 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 Environments 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 Environments 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 Environments server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class EnvironmentsRestStub: - _session: AuthorizedSession - _host: str - _interceptor: EnvironmentsRestInterceptor - - -class EnvironmentsRestTransport(EnvironmentsTransport): - """REST backend transport for Environments. - - Service for managing - [Environments][google.cloud.dialogflow.cx.v3.Environment]. - - 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 = 'dialogflow.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[EnvironmentsRestInterceptor] = 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 EnvironmentsRestInterceptor() - 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': '/v3/{name=projects/*/operations/*}:cancel', - }, - { - 'method': 'post', - 'uri': '/v3/{name=projects/*/locations/*/operations/*}:cancel', - }, - ], - 'google.longrunning.Operations.GetOperation': [ - { - 'method': 'get', - 'uri': '/v3/{name=projects/*/operations/*}', - }, - { - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/operations/*}', - }, - ], - 'google.longrunning.Operations.ListOperations': [ - { - 'method': 'get', - 'uri': '/v3/{name=projects/*}/operations', - }, - { - 'method': 'get', - 'uri': '/v3/{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="v3") - - self._operations_client = operations_v1.AbstractOperationsClient(transport=rest_transport) - - # Return the client from cache. - return self._operations_client - - class _CreateEnvironment(EnvironmentsRestStub): - def __hash__(self): - return hash("CreateEnvironment") - - __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: gcdc_environment.CreateEnvironmentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the create environment method over HTTP. - - Args: - request (~.gcdc_environment.CreateEnvironmentRequest): - The request object. The request message for - [Environments.CreateEnvironment][google.cloud.dialogflow.cx.v3.Environments.CreateEnvironment]. - 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': '/v3/{parent=projects/*/locations/*/agents/*}/environments', - 'body': 'environment', - }, - ] - request, metadata = self._interceptor.pre_create_environment(request, metadata) - pb_request = gcdc_environment.CreateEnvironmentRequest.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_environment(resp) - return resp - - class _DeleteEnvironment(EnvironmentsRestStub): - def __hash__(self): - return hash("DeleteEnvironment") - - __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: environment.DeleteEnvironmentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete environment method over HTTP. - - Args: - request (~.environment.DeleteEnvironmentRequest): - The request object. The request message for - [Environments.DeleteEnvironment][google.cloud.dialogflow.cx.v3.Environments.DeleteEnvironment]. - 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': '/v3/{name=projects/*/locations/*/agents/*/environments/*}', - }, - ] - request, metadata = self._interceptor.pre_delete_environment(request, metadata) - pb_request = environment.DeleteEnvironmentRequest.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 _DeployFlow(EnvironmentsRestStub): - def __hash__(self): - return hash("DeployFlow") - - __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: environment.DeployFlowRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the deploy flow method over HTTP. - - Args: - request (~.environment.DeployFlowRequest): - The request object. The request message for - [Environments.DeployFlow][google.cloud.dialogflow.cx.v3.Environments.DeployFlow]. - 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': '/v3/{environment=projects/*/locations/*/agents/*/environments/*}:deployFlow', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_deploy_flow(request, metadata) - pb_request = environment.DeployFlowRequest.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_flow(resp) - return resp - - class _GetEnvironment(EnvironmentsRestStub): - def __hash__(self): - return hash("GetEnvironment") - - __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: environment.GetEnvironmentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> environment.Environment: - r"""Call the get environment method over HTTP. - - Args: - request (~.environment.GetEnvironmentRequest): - The request object. The request message for - [Environments.GetEnvironment][google.cloud.dialogflow.cx.v3.Environments.GetEnvironment]. - 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: - ~.environment.Environment: - Represents an environment for an - agent. You can create multiple versions - of your agent and publish them to - separate environments. When you edit an - agent, you are editing the draft agent. - At any point, you can save the draft - agent as an agent version, which is an - immutable snapshot of your agent. When - you save the draft agent, it is - published to the default environment. - When you create agent versions, you can - publish them to custom environments. You - can create a variety of custom - environments for testing, development, - production, etc. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/environments/*}', - }, - ] - request, metadata = self._interceptor.pre_get_environment(request, metadata) - pb_request = environment.GetEnvironmentRequest.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 = environment.Environment() - pb_resp = environment.Environment.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_environment(resp) - return resp - - class _ListContinuousTestResults(EnvironmentsRestStub): - def __hash__(self): - return hash("ListContinuousTestResults") - - __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: environment.ListContinuousTestResultsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> environment.ListContinuousTestResultsResponse: - r"""Call the list continuous test - results method over HTTP. - - Args: - request (~.environment.ListContinuousTestResultsRequest): - The request object. The request message for - [Environments.ListContinuousTestResults][google.cloud.dialogflow.cx.v3.Environments.ListContinuousTestResults]. - 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: - ~.environment.ListContinuousTestResultsResponse: - The response message for - [Environments.ListTestCaseResults][]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*/environments/*}/continuousTestResults', - }, - ] - request, metadata = self._interceptor.pre_list_continuous_test_results(request, metadata) - pb_request = environment.ListContinuousTestResultsRequest.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 = environment.ListContinuousTestResultsResponse() - pb_resp = environment.ListContinuousTestResultsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_continuous_test_results(resp) - return resp - - class _ListEnvironments(EnvironmentsRestStub): - def __hash__(self): - return hash("ListEnvironments") - - __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: environment.ListEnvironmentsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> environment.ListEnvironmentsResponse: - r"""Call the list environments method over HTTP. - - Args: - request (~.environment.ListEnvironmentsRequest): - The request object. The request message for - [Environments.ListEnvironments][google.cloud.dialogflow.cx.v3.Environments.ListEnvironments]. - 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: - ~.environment.ListEnvironmentsResponse: - The response message for - [Environments.ListEnvironments][google.cloud.dialogflow.cx.v3.Environments.ListEnvironments]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*}/environments', - }, - ] - request, metadata = self._interceptor.pre_list_environments(request, metadata) - pb_request = environment.ListEnvironmentsRequest.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 = environment.ListEnvironmentsResponse() - pb_resp = environment.ListEnvironmentsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_environments(resp) - return resp - - class _LookupEnvironmentHistory(EnvironmentsRestStub): - def __hash__(self): - return hash("LookupEnvironmentHistory") - - __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: environment.LookupEnvironmentHistoryRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> environment.LookupEnvironmentHistoryResponse: - r"""Call the lookup environment - history method over HTTP. - - Args: - request (~.environment.LookupEnvironmentHistoryRequest): - The request object. The request message for - [Environments.LookupEnvironmentHistory][google.cloud.dialogflow.cx.v3.Environments.LookupEnvironmentHistory]. - 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: - ~.environment.LookupEnvironmentHistoryResponse: - The response message for - [Environments.LookupEnvironmentHistory][google.cloud.dialogflow.cx.v3.Environments.LookupEnvironmentHistory]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/environments/*}:lookupEnvironmentHistory', - }, - ] - request, metadata = self._interceptor.pre_lookup_environment_history(request, metadata) - pb_request = environment.LookupEnvironmentHistoryRequest.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 = environment.LookupEnvironmentHistoryResponse() - pb_resp = environment.LookupEnvironmentHistoryResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_lookup_environment_history(resp) - return resp - - class _RunContinuousTest(EnvironmentsRestStub): - def __hash__(self): - return hash("RunContinuousTest") - - __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: environment.RunContinuousTestRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the run continuous test method over HTTP. - - Args: - request (~.environment.RunContinuousTestRequest): - The request object. The request message for - [Environments.RunContinuousTest][google.cloud.dialogflow.cx.v3.Environments.RunContinuousTest]. - 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': '/v3/{environment=projects/*/locations/*/agents/*/environments/*}:runContinuousTest', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_run_continuous_test(request, metadata) - pb_request = environment.RunContinuousTestRequest.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_run_continuous_test(resp) - return resp - - class _UpdateEnvironment(EnvironmentsRestStub): - def __hash__(self): - return hash("UpdateEnvironment") - - __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: gcdc_environment.UpdateEnvironmentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the update environment method over HTTP. - - Args: - request (~.gcdc_environment.UpdateEnvironmentRequest): - The request object. The request message for - [Environments.UpdateEnvironment][google.cloud.dialogflow.cx.v3.Environments.UpdateEnvironment]. - 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': 'patch', - 'uri': '/v3/{environment.name=projects/*/locations/*/agents/*/environments/*}', - 'body': 'environment', - }, - ] - request, metadata = self._interceptor.pre_update_environment(request, metadata) - pb_request = gcdc_environment.UpdateEnvironmentRequest.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_update_environment(resp) - return resp - - @property - def create_environment(self) -> Callable[ - [gcdc_environment.CreateEnvironmentRequest], - 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._CreateEnvironment(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_environment(self) -> Callable[ - [environment.DeleteEnvironmentRequest], - 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._DeleteEnvironment(self._session, self._host, self._interceptor) # type: ignore - - @property - def deploy_flow(self) -> Callable[ - [environment.DeployFlowRequest], - 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._DeployFlow(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_environment(self) -> Callable[ - [environment.GetEnvironmentRequest], - environment.Environment]: - # 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._GetEnvironment(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_continuous_test_results(self) -> Callable[ - [environment.ListContinuousTestResultsRequest], - environment.ListContinuousTestResultsResponse]: - # 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._ListContinuousTestResults(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_environments(self) -> Callable[ - [environment.ListEnvironmentsRequest], - environment.ListEnvironmentsResponse]: - # 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._ListEnvironments(self._session, self._host, self._interceptor) # type: ignore - - @property - def lookup_environment_history(self) -> Callable[ - [environment.LookupEnvironmentHistoryRequest], - environment.LookupEnvironmentHistoryResponse]: - # 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._LookupEnvironmentHistory(self._session, self._host, self._interceptor) # type: ignore - - @property - def run_continuous_test(self) -> Callable[ - [environment.RunContinuousTestRequest], - 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._RunContinuousTest(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_environment(self) -> Callable[ - [gcdc_environment.UpdateEnvironmentRequest], - 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._UpdateEnvironment(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_location(self): - return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore - - class _GetLocation(EnvironmentsRestStub): - def __call__(self, - request: locations_pb2.GetLocationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.Location: - - r"""Call the get location method over HTTP. - - Args: - request (locations_pb2.GetLocationRequest): - The request object for GetLocation 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: - locations_pb2.Location: Response from GetLocation method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*}', - }, - ] - - request, metadata = self._interceptor.pre_get_location(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 = locations_pb2.Location() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_get_location(resp) - return resp - - @property - def list_locations(self): - return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore - - class _ListLocations(EnvironmentsRestStub): - def __call__(self, - request: locations_pb2.ListLocationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.ListLocationsResponse: - - r"""Call the list locations method over HTTP. - - Args: - request (locations_pb2.ListLocationsRequest): - The request object for ListLocations 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: - locations_pb2.ListLocationsResponse: Response from ListLocations method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*}/locations', - }, - ] - - request, metadata = self._interceptor.pre_list_locations(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 = locations_pb2.ListLocationsResponse() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_list_locations(resp) - return resp - - @property - def cancel_operation(self): - return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore - - class _CancelOperation(EnvironmentsRestStub): - 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': '/v3/{name=projects/*/operations/*}:cancel', - }, -{ - 'method': 'post', - 'uri': '/v3/{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(EnvironmentsRestStub): - 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': '/v3/{name=projects/*/operations/*}', - }, -{ - 'method': 'get', - 'uri': '/v3/{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(EnvironmentsRestStub): - 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': '/v3/{name=projects/*}/operations', - }, -{ - 'method': 'get', - 'uri': '/v3/{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__=( - 'EnvironmentsRestTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/__init__.py deleted file mode 100644 index e26b2132..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/__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 ExperimentsClient -from .async_client import ExperimentsAsyncClient - -__all__ = ( - 'ExperimentsClient', - 'ExperimentsAsyncClient', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/async_client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/async_client.py deleted file mode 100644 index 00412d6e..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/async_client.py +++ /dev/null @@ -1,1216 +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.dialogflowcx_v3 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.cloud.dialogflowcx_v3.services.experiments import pagers -from google.cloud.dialogflowcx_v3.types import experiment -from google.cloud.dialogflowcx_v3.types import experiment as gcdc_experiment -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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 .transports.base import ExperimentsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import ExperimentsGrpcAsyncIOTransport -from .client import ExperimentsClient - - -class ExperimentsAsyncClient: - """Service for managing - [Experiments][google.cloud.dialogflow.cx.v3.Experiment]. - """ - - _client: ExperimentsClient - - DEFAULT_ENDPOINT = ExperimentsClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = ExperimentsClient.DEFAULT_MTLS_ENDPOINT - - experiment_path = staticmethod(ExperimentsClient.experiment_path) - parse_experiment_path = staticmethod(ExperimentsClient.parse_experiment_path) - version_path = staticmethod(ExperimentsClient.version_path) - parse_version_path = staticmethod(ExperimentsClient.parse_version_path) - common_billing_account_path = staticmethod(ExperimentsClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(ExperimentsClient.parse_common_billing_account_path) - common_folder_path = staticmethod(ExperimentsClient.common_folder_path) - parse_common_folder_path = staticmethod(ExperimentsClient.parse_common_folder_path) - common_organization_path = staticmethod(ExperimentsClient.common_organization_path) - parse_common_organization_path = staticmethod(ExperimentsClient.parse_common_organization_path) - common_project_path = staticmethod(ExperimentsClient.common_project_path) - parse_common_project_path = staticmethod(ExperimentsClient.parse_common_project_path) - common_location_path = staticmethod(ExperimentsClient.common_location_path) - parse_common_location_path = staticmethod(ExperimentsClient.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: - ExperimentsAsyncClient: The constructed client. - """ - return ExperimentsClient.from_service_account_info.__func__(ExperimentsAsyncClient, 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: - ExperimentsAsyncClient: The constructed client. - """ - return ExperimentsClient.from_service_account_file.__func__(ExperimentsAsyncClient, 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 ExperimentsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> ExperimentsTransport: - """Returns the transport used by the client instance. - - Returns: - ExperimentsTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(ExperimentsClient).get_transport_class, type(ExperimentsClient)) - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, ExperimentsTransport] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the experiments 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, ~.ExperimentsTransport]): 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 = ExperimentsClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def list_experiments(self, - request: Optional[Union[experiment.ListExperimentsRequest, 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.ListExperimentsAsyncPager: - r"""Returns the list of all experiments in the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - .. 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 dialogflowcx_v3 - - async def sample_list_experiments(): - # Create a client - client = dialogflowcx_v3.ExperimentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListExperimentsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_experiments(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ListExperimentsRequest, dict]]): - The request object. The request message for - [Experiments.ListExperiments][google.cloud.dialogflow.cx.v3.Experiments.ListExperiments]. - parent (:class:`str`): - Required. The - [Environment][google.cloud.dialogflow.cx.v3.Environment] - to list all environments for. Format: - ``projects//locations//agents//environments/``. - - 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.dialogflowcx_v3.services.experiments.pagers.ListExperimentsAsyncPager: - The response message for - [Experiments.ListExperiments][google.cloud.dialogflow.cx.v3.Experiments.ListExperiments]. - - 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 = experiment.ListExperimentsRequest(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_experiments, - 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.ListExperimentsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_experiment(self, - request: Optional[Union[experiment.GetExperimentRequest, 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]] = (), - ) -> experiment.Experiment: - r"""Retrieves the specified - [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. - - .. 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 dialogflowcx_v3 - - async def sample_get_experiment(): - # Create a client - client = dialogflowcx_v3.ExperimentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetExperimentRequest( - name="name_value", - ) - - # Make the request - response = await client.get_experiment(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.GetExperimentRequest, dict]]): - The request object. The request message for - [Experiments.GetExperiment][google.cloud.dialogflow.cx.v3.Experiments.GetExperiment]. - name (:class:`str`): - Required. The name of the - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - Format: - ``projects//locations//agents//environments//experiments/``. - - 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.dialogflowcx_v3.types.Experiment: - Represents an experiment in an - environment. - - """ - # 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 = experiment.GetExperimentRequest(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_experiment, - 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 create_experiment(self, - request: Optional[Union[gcdc_experiment.CreateExperimentRequest, dict]] = None, - *, - parent: Optional[str] = None, - experiment: Optional[gcdc_experiment.Experiment] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_experiment.Experiment: - r"""Creates an - [Experiment][google.cloud.dialogflow.cx.v3.Experiment] in the - specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - .. 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 dialogflowcx_v3 - - async def sample_create_experiment(): - # Create a client - client = dialogflowcx_v3.ExperimentsAsyncClient() - - # Initialize request argument(s) - experiment = dialogflowcx_v3.Experiment() - experiment.display_name = "display_name_value" - - request = dialogflowcx_v3.CreateExperimentRequest( - parent="parent_value", - experiment=experiment, - ) - - # Make the request - response = await client.create_experiment(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.CreateExperimentRequest, dict]]): - The request object. The request message for - [Experiments.CreateExperiment][google.cloud.dialogflow.cx.v3.Experiments.CreateExperiment]. - parent (:class:`str`): - Required. The - [Agent][google.cloud.dialogflow.cx.v3.Agent] to create - an - [Environment][google.cloud.dialogflow.cx.v3.Environment] - for. Format: - ``projects//locations//agents//environments/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - experiment (:class:`google.cloud.dialogflowcx_v3.types.Experiment`): - Required. The experiment to create. - This corresponds to the ``experiment`` 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.dialogflowcx_v3.types.Experiment: - Represents an experiment in an - environment. - - """ - # 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, experiment]) - 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 = gcdc_experiment.CreateExperimentRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if experiment is not None: - request.experiment = experiment - - # 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_experiment, - 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_experiment(self, - request: Optional[Union[gcdc_experiment.UpdateExperimentRequest, dict]] = None, - *, - experiment: Optional[gcdc_experiment.Experiment] = 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]] = (), - ) -> gcdc_experiment.Experiment: - r"""Updates the specified - [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. - - .. 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 dialogflowcx_v3 - - async def sample_update_experiment(): - # Create a client - client = dialogflowcx_v3.ExperimentsAsyncClient() - - # Initialize request argument(s) - experiment = dialogflowcx_v3.Experiment() - experiment.display_name = "display_name_value" - - request = dialogflowcx_v3.UpdateExperimentRequest( - experiment=experiment, - ) - - # Make the request - response = await client.update_experiment(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.UpdateExperimentRequest, dict]]): - The request object. The request message for - [Experiments.UpdateExperiment][google.cloud.dialogflow.cx.v3.Experiments.UpdateExperiment]. - experiment (:class:`google.cloud.dialogflowcx_v3.types.Experiment`): - Required. The experiment to update. - This corresponds to the ``experiment`` 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 mask to control which - fields get 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.dialogflowcx_v3.types.Experiment: - Represents an experiment in an - environment. - - """ - # 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([experiment, 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 = gcdc_experiment.UpdateExperimentRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if experiment is not None: - request.experiment = experiment - 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_experiment, - 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(( - ("experiment.name", request.experiment.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_experiment(self, - request: Optional[Union[experiment.DeleteExperimentRequest, 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 the specified - [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. - - .. 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 dialogflowcx_v3 - - async def sample_delete_experiment(): - # Create a client - client = dialogflowcx_v3.ExperimentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteExperimentRequest( - name="name_value", - ) - - # Make the request - await client.delete_experiment(request=request) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.DeleteExperimentRequest, dict]]): - The request object. The request message for - [Experiments.DeleteExperiment][google.cloud.dialogflow.cx.v3.Experiments.DeleteExperiment]. - name (:class:`str`): - Required. The name of the - [Environment][google.cloud.dialogflow.cx.v3.Environment] - to delete. Format: - ``projects//locations//agents//environments//experiments/``. - - 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 = experiment.DeleteExperimentRequest(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_experiment, - 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 start_experiment(self, - request: Optional[Union[experiment.StartExperimentRequest, 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]] = (), - ) -> experiment.Experiment: - r"""Starts the specified - [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. This rpc - only changes the state of experiment from PENDING to RUNNING. - - .. 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 dialogflowcx_v3 - - async def sample_start_experiment(): - # Create a client - client = dialogflowcx_v3.ExperimentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.StartExperimentRequest( - name="name_value", - ) - - # Make the request - response = await client.start_experiment(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.StartExperimentRequest, dict]]): - The request object. The request message for - [Experiments.StartExperiment][google.cloud.dialogflow.cx.v3.Experiments.StartExperiment]. - name (:class:`str`): - Required. Resource name of the experiment to start. - Format: - ``projects//locations//agents//environments//experiments/``. - - 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.dialogflowcx_v3.types.Experiment: - Represents an experiment in an - environment. - - """ - # 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 = experiment.StartExperimentRequest(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.start_experiment, - 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 stop_experiment(self, - request: Optional[Union[experiment.StopExperimentRequest, 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]] = (), - ) -> experiment.Experiment: - r"""Stops the specified - [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. This rpc - only changes the state of experiment from RUNNING to DONE. - - .. 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 dialogflowcx_v3 - - async def sample_stop_experiment(): - # Create a client - client = dialogflowcx_v3.ExperimentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.StopExperimentRequest( - name="name_value", - ) - - # Make the request - response = await client.stop_experiment(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.StopExperimentRequest, dict]]): - The request object. The request message for - [Experiments.StopExperiment][google.cloud.dialogflow.cx.v3.Experiments.StopExperiment]. - name (:class:`str`): - Required. Resource name of the experiment to stop. - Format: - ``projects//locations//agents//environments//experiments/``. - - 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.dialogflowcx_v3.types.Experiment: - Represents an experiment in an - environment. - - """ - # 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 = experiment.StopExperimentRequest(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.stop_experiment, - 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_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 get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**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_location, - 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_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**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_locations, - 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 __aenter__(self) -> "ExperimentsAsyncClient": - 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__ = ( - "ExperimentsAsyncClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/client.py deleted file mode 100644 index 08d62a47..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/client.py +++ /dev/null @@ -1,1424 +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.dialogflowcx_v3 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.cloud.dialogflowcx_v3.services.experiments import pagers -from google.cloud.dialogflowcx_v3.types import experiment -from google.cloud.dialogflowcx_v3.types import experiment as gcdc_experiment -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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 .transports.base import ExperimentsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import ExperimentsGrpcTransport -from .transports.grpc_asyncio import ExperimentsGrpcAsyncIOTransport -from .transports.rest import ExperimentsRestTransport - - -class ExperimentsClientMeta(type): - """Metaclass for the Experiments 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[ExperimentsTransport]] - _transport_registry["grpc"] = ExperimentsGrpcTransport - _transport_registry["grpc_asyncio"] = ExperimentsGrpcAsyncIOTransport - _transport_registry["rest"] = ExperimentsRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[ExperimentsTransport]: - """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 ExperimentsClient(metaclass=ExperimentsClientMeta): - """Service for managing - [Experiments][google.cloud.dialogflow.cx.v3.Experiment]. - """ - - @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 = "dialogflow.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: - ExperimentsClient: 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: - ExperimentsClient: 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) -> ExperimentsTransport: - """Returns the transport used by the client instance. - - Returns: - ExperimentsTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def experiment_path(project: str,location: str,agent: str,environment: str,experiment: str,) -> str: - """Returns a fully-qualified experiment string.""" - return "projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/experiments/{experiment}".format(project=project, location=location, agent=agent, environment=environment, experiment=experiment, ) - - @staticmethod - def parse_experiment_path(path: str) -> Dict[str,str]: - """Parses a experiment path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/environments/(?P.+?)/experiments/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def version_path(project: str,location: str,agent: str,flow: str,version: str,) -> str: - """Returns a fully-qualified version string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version}".format(project=project, location=location, agent=agent, flow=flow, version=version, ) - - @staticmethod - def parse_version_path(path: str) -> Dict[str,str]: - """Parses a version path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)/versions/(?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, ExperimentsTransport]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the experiments 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, ExperimentsTransport]): 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, ExperimentsTransport): - # transport is a ExperimentsTransport 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 list_experiments(self, - request: Optional[Union[experiment.ListExperimentsRequest, 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.ListExperimentsPager: - r"""Returns the list of all experiments in the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - .. 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 dialogflowcx_v3 - - def sample_list_experiments(): - # Create a client - client = dialogflowcx_v3.ExperimentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListExperimentsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_experiments(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ListExperimentsRequest, dict]): - The request object. The request message for - [Experiments.ListExperiments][google.cloud.dialogflow.cx.v3.Experiments.ListExperiments]. - parent (str): - Required. The - [Environment][google.cloud.dialogflow.cx.v3.Environment] - to list all environments for. Format: - ``projects//locations//agents//environments/``. - - 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.dialogflowcx_v3.services.experiments.pagers.ListExperimentsPager: - The response message for - [Experiments.ListExperiments][google.cloud.dialogflow.cx.v3.Experiments.ListExperiments]. - - 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 experiment.ListExperimentsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, experiment.ListExperimentsRequest): - request = experiment.ListExperimentsRequest(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_experiments] - - # 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.ListExperimentsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_experiment(self, - request: Optional[Union[experiment.GetExperimentRequest, 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]] = (), - ) -> experiment.Experiment: - r"""Retrieves the specified - [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. - - .. 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 dialogflowcx_v3 - - def sample_get_experiment(): - # Create a client - client = dialogflowcx_v3.ExperimentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetExperimentRequest( - name="name_value", - ) - - # Make the request - response = client.get_experiment(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.GetExperimentRequest, dict]): - The request object. The request message for - [Experiments.GetExperiment][google.cloud.dialogflow.cx.v3.Experiments.GetExperiment]. - name (str): - Required. The name of the - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - Format: - ``projects//locations//agents//environments//experiments/``. - - 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.dialogflowcx_v3.types.Experiment: - Represents an experiment in an - environment. - - """ - # 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 experiment.GetExperimentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, experiment.GetExperimentRequest): - request = experiment.GetExperimentRequest(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_experiment] - - # 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 create_experiment(self, - request: Optional[Union[gcdc_experiment.CreateExperimentRequest, dict]] = None, - *, - parent: Optional[str] = None, - experiment: Optional[gcdc_experiment.Experiment] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_experiment.Experiment: - r"""Creates an - [Experiment][google.cloud.dialogflow.cx.v3.Experiment] in the - specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - .. 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 dialogflowcx_v3 - - def sample_create_experiment(): - # Create a client - client = dialogflowcx_v3.ExperimentsClient() - - # Initialize request argument(s) - experiment = dialogflowcx_v3.Experiment() - experiment.display_name = "display_name_value" - - request = dialogflowcx_v3.CreateExperimentRequest( - parent="parent_value", - experiment=experiment, - ) - - # Make the request - response = client.create_experiment(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.CreateExperimentRequest, dict]): - The request object. The request message for - [Experiments.CreateExperiment][google.cloud.dialogflow.cx.v3.Experiments.CreateExperiment]. - parent (str): - Required. The - [Agent][google.cloud.dialogflow.cx.v3.Agent] to create - an - [Environment][google.cloud.dialogflow.cx.v3.Environment] - for. Format: - ``projects//locations//agents//environments/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - experiment (google.cloud.dialogflowcx_v3.types.Experiment): - Required. The experiment to create. - This corresponds to the ``experiment`` 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.dialogflowcx_v3.types.Experiment: - Represents an experiment in an - environment. - - """ - # 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, experiment]) - 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 gcdc_experiment.CreateExperimentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_experiment.CreateExperimentRequest): - request = gcdc_experiment.CreateExperimentRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if experiment is not None: - request.experiment = experiment - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_experiment] - - # 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_experiment(self, - request: Optional[Union[gcdc_experiment.UpdateExperimentRequest, dict]] = None, - *, - experiment: Optional[gcdc_experiment.Experiment] = 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]] = (), - ) -> gcdc_experiment.Experiment: - r"""Updates the specified - [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. - - .. 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 dialogflowcx_v3 - - def sample_update_experiment(): - # Create a client - client = dialogflowcx_v3.ExperimentsClient() - - # Initialize request argument(s) - experiment = dialogflowcx_v3.Experiment() - experiment.display_name = "display_name_value" - - request = dialogflowcx_v3.UpdateExperimentRequest( - experiment=experiment, - ) - - # Make the request - response = client.update_experiment(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.UpdateExperimentRequest, dict]): - The request object. The request message for - [Experiments.UpdateExperiment][google.cloud.dialogflow.cx.v3.Experiments.UpdateExperiment]. - experiment (google.cloud.dialogflowcx_v3.types.Experiment): - Required. The experiment to update. - This corresponds to the ``experiment`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The mask to control which - fields get 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.dialogflowcx_v3.types.Experiment: - Represents an experiment in an - environment. - - """ - # 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([experiment, 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 gcdc_experiment.UpdateExperimentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_experiment.UpdateExperimentRequest): - request = gcdc_experiment.UpdateExperimentRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if experiment is not None: - request.experiment = experiment - 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_experiment] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("experiment.name", request.experiment.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_experiment(self, - request: Optional[Union[experiment.DeleteExperimentRequest, 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 the specified - [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. - - .. 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 dialogflowcx_v3 - - def sample_delete_experiment(): - # Create a client - client = dialogflowcx_v3.ExperimentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteExperimentRequest( - name="name_value", - ) - - # Make the request - client.delete_experiment(request=request) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.DeleteExperimentRequest, dict]): - The request object. The request message for - [Experiments.DeleteExperiment][google.cloud.dialogflow.cx.v3.Experiments.DeleteExperiment]. - name (str): - Required. The name of the - [Environment][google.cloud.dialogflow.cx.v3.Environment] - to delete. Format: - ``projects//locations//agents//environments//experiments/``. - - 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 experiment.DeleteExperimentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, experiment.DeleteExperimentRequest): - request = experiment.DeleteExperimentRequest(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_experiment] - - # 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 start_experiment(self, - request: Optional[Union[experiment.StartExperimentRequest, 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]] = (), - ) -> experiment.Experiment: - r"""Starts the specified - [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. This rpc - only changes the state of experiment from PENDING to RUNNING. - - .. 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 dialogflowcx_v3 - - def sample_start_experiment(): - # Create a client - client = dialogflowcx_v3.ExperimentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.StartExperimentRequest( - name="name_value", - ) - - # Make the request - response = client.start_experiment(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.StartExperimentRequest, dict]): - The request object. The request message for - [Experiments.StartExperiment][google.cloud.dialogflow.cx.v3.Experiments.StartExperiment]. - name (str): - Required. Resource name of the experiment to start. - Format: - ``projects//locations//agents//environments//experiments/``. - - 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.dialogflowcx_v3.types.Experiment: - Represents an experiment in an - environment. - - """ - # 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 experiment.StartExperimentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, experiment.StartExperimentRequest): - request = experiment.StartExperimentRequest(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.start_experiment] - - # 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 stop_experiment(self, - request: Optional[Union[experiment.StopExperimentRequest, 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]] = (), - ) -> experiment.Experiment: - r"""Stops the specified - [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. This rpc - only changes the state of experiment from RUNNING to DONE. - - .. 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 dialogflowcx_v3 - - def sample_stop_experiment(): - # Create a client - client = dialogflowcx_v3.ExperimentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.StopExperimentRequest( - name="name_value", - ) - - # Make the request - response = client.stop_experiment(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.StopExperimentRequest, dict]): - The request object. The request message for - [Experiments.StopExperiment][google.cloud.dialogflow.cx.v3.Experiments.StopExperiment]. - name (str): - Required. Resource name of the experiment to stop. - Format: - ``projects//locations//agents//environments//experiments/``. - - 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.dialogflowcx_v3.types.Experiment: - Represents an experiment in an - environment. - - """ - # 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 experiment.StopExperimentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, experiment.StopExperimentRequest): - request = experiment.StopExperimentRequest(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.stop_experiment] - - # 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 __enter__(self) -> "ExperimentsClient": - 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,) - - def get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.get_location, - 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 list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.list_locations, - 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 - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "ExperimentsClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/pagers.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/pagers.py deleted file mode 100644 index a746a176..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/pagers.py +++ /dev/null @@ -1,139 +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.dialogflowcx_v3.types import experiment - - -class ListExperimentsPager: - """A pager for iterating through ``list_experiments`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListExperimentsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``experiments`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListExperiments`` requests and continue to iterate - through the ``experiments`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListExperimentsResponse` - 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[..., experiment.ListExperimentsResponse], - request: experiment.ListExperimentsRequest, - response: experiment.ListExperimentsResponse, - *, - 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.dialogflowcx_v3.types.ListExperimentsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListExperimentsResponse): - 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 = experiment.ListExperimentsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[experiment.ListExperimentsResponse]: - 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[experiment.Experiment]: - for page in self.pages: - yield from page.experiments - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListExperimentsAsyncPager: - """A pager for iterating through ``list_experiments`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListExperimentsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``experiments`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListExperiments`` requests and continue to iterate - through the ``experiments`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListExperimentsResponse` - 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[experiment.ListExperimentsResponse]], - request: experiment.ListExperimentsRequest, - response: experiment.ListExperimentsResponse, - *, - 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.dialogflowcx_v3.types.ListExperimentsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListExperimentsResponse): - 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 = experiment.ListExperimentsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[experiment.ListExperimentsResponse]: - 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[experiment.Experiment]: - async def async_generator(): - async for page in self.pages: - for response in page.experiments: - 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/v3/google/cloud/dialogflowcx_v3/services/experiments/transports/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/transports/__init__.py deleted file mode 100644 index 4706fbbc..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/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 ExperimentsTransport -from .grpc import ExperimentsGrpcTransport -from .grpc_asyncio import ExperimentsGrpcAsyncIOTransport -from .rest import ExperimentsRestTransport -from .rest import ExperimentsRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[ExperimentsTransport]] -_transport_registry['grpc'] = ExperimentsGrpcTransport -_transport_registry['grpc_asyncio'] = ExperimentsGrpcAsyncIOTransport -_transport_registry['rest'] = ExperimentsRestTransport - -__all__ = ( - 'ExperimentsTransport', - 'ExperimentsGrpcTransport', - 'ExperimentsGrpcAsyncIOTransport', - 'ExperimentsRestTransport', - 'ExperimentsRestInterceptor', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/transports/base.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/transports/base.py deleted file mode 100644 index c9e74864..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/transports/base.py +++ /dev/null @@ -1,280 +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.dialogflowcx_v3 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.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.dialogflowcx_v3.types import experiment -from google.cloud.dialogflowcx_v3.types import experiment as gcdc_experiment -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -class ExperimentsTransport(abc.ABC): - """Abstract transport class for Experiments.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/dialogflow', - ) - - DEFAULT_HOST: str = 'dialogflow.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.list_experiments: gapic_v1.method.wrap_method( - self.list_experiments, - default_timeout=None, - client_info=client_info, - ), - self.get_experiment: gapic_v1.method.wrap_method( - self.get_experiment, - default_timeout=None, - client_info=client_info, - ), - self.create_experiment: gapic_v1.method.wrap_method( - self.create_experiment, - default_timeout=None, - client_info=client_info, - ), - self.update_experiment: gapic_v1.method.wrap_method( - self.update_experiment, - default_timeout=None, - client_info=client_info, - ), - self.delete_experiment: gapic_v1.method.wrap_method( - self.delete_experiment, - default_timeout=None, - client_info=client_info, - ), - self.start_experiment: gapic_v1.method.wrap_method( - self.start_experiment, - default_timeout=None, - client_info=client_info, - ), - self.stop_experiment: gapic_v1.method.wrap_method( - self.stop_experiment, - 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 list_experiments(self) -> Callable[ - [experiment.ListExperimentsRequest], - Union[ - experiment.ListExperimentsResponse, - Awaitable[experiment.ListExperimentsResponse] - ]]: - raise NotImplementedError() - - @property - def get_experiment(self) -> Callable[ - [experiment.GetExperimentRequest], - Union[ - experiment.Experiment, - Awaitable[experiment.Experiment] - ]]: - raise NotImplementedError() - - @property - def create_experiment(self) -> Callable[ - [gcdc_experiment.CreateExperimentRequest], - Union[ - gcdc_experiment.Experiment, - Awaitable[gcdc_experiment.Experiment] - ]]: - raise NotImplementedError() - - @property - def update_experiment(self) -> Callable[ - [gcdc_experiment.UpdateExperimentRequest], - Union[ - gcdc_experiment.Experiment, - Awaitable[gcdc_experiment.Experiment] - ]]: - raise NotImplementedError() - - @property - def delete_experiment(self) -> Callable[ - [experiment.DeleteExperimentRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def start_experiment(self) -> Callable[ - [experiment.StartExperimentRequest], - Union[ - experiment.Experiment, - Awaitable[experiment.Experiment] - ]]: - raise NotImplementedError() - - @property - def stop_experiment(self) -> Callable[ - [experiment.StopExperimentRequest], - Union[ - experiment.Experiment, - Awaitable[experiment.Experiment] - ]]: - 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 get_location(self, - ) -> Callable[ - [locations_pb2.GetLocationRequest], - Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], - ]: - raise NotImplementedError() - - @property - def list_locations(self, - ) -> Callable[ - [locations_pb2.ListLocationsRequest], - Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'ExperimentsTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc.py deleted file mode 100644 index f2fb5b43..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc.py +++ /dev/null @@ -1,526 +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 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.dialogflowcx_v3.types import experiment -from google.cloud.dialogflowcx_v3.types import experiment as gcdc_experiment -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from .base import ExperimentsTransport, DEFAULT_CLIENT_INFO - - -class ExperimentsGrpcTransport(ExperimentsTransport): - """gRPC backend transport for Experiments. - - Service for managing - [Experiments][google.cloud.dialogflow.cx.v3.Experiment]. - - 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 = 'dialogflow.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] = {} - - 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 = 'dialogflow.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 list_experiments(self) -> Callable[ - [experiment.ListExperimentsRequest], - experiment.ListExperimentsResponse]: - r"""Return a callable for the list experiments method over gRPC. - - Returns the list of all experiments in the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - Returns: - Callable[[~.ListExperimentsRequest], - ~.ListExperimentsResponse]: - 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_experiments' not in self._stubs: - self._stubs['list_experiments'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Experiments/ListExperiments', - request_serializer=experiment.ListExperimentsRequest.serialize, - response_deserializer=experiment.ListExperimentsResponse.deserialize, - ) - return self._stubs['list_experiments'] - - @property - def get_experiment(self) -> Callable[ - [experiment.GetExperimentRequest], - experiment.Experiment]: - r"""Return a callable for the get experiment method over gRPC. - - Retrieves the specified - [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. - - Returns: - Callable[[~.GetExperimentRequest], - ~.Experiment]: - 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_experiment' not in self._stubs: - self._stubs['get_experiment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Experiments/GetExperiment', - request_serializer=experiment.GetExperimentRequest.serialize, - response_deserializer=experiment.Experiment.deserialize, - ) - return self._stubs['get_experiment'] - - @property - def create_experiment(self) -> Callable[ - [gcdc_experiment.CreateExperimentRequest], - gcdc_experiment.Experiment]: - r"""Return a callable for the create experiment method over gRPC. - - Creates an - [Experiment][google.cloud.dialogflow.cx.v3.Experiment] in the - specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - Returns: - Callable[[~.CreateExperimentRequest], - ~.Experiment]: - 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_experiment' not in self._stubs: - self._stubs['create_experiment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Experiments/CreateExperiment', - request_serializer=gcdc_experiment.CreateExperimentRequest.serialize, - response_deserializer=gcdc_experiment.Experiment.deserialize, - ) - return self._stubs['create_experiment'] - - @property - def update_experiment(self) -> Callable[ - [gcdc_experiment.UpdateExperimentRequest], - gcdc_experiment.Experiment]: - r"""Return a callable for the update experiment method over gRPC. - - Updates the specified - [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. - - Returns: - Callable[[~.UpdateExperimentRequest], - ~.Experiment]: - 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_experiment' not in self._stubs: - self._stubs['update_experiment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Experiments/UpdateExperiment', - request_serializer=gcdc_experiment.UpdateExperimentRequest.serialize, - response_deserializer=gcdc_experiment.Experiment.deserialize, - ) - return self._stubs['update_experiment'] - - @property - def delete_experiment(self) -> Callable[ - [experiment.DeleteExperimentRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete experiment method over gRPC. - - Deletes the specified - [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. - - Returns: - Callable[[~.DeleteExperimentRequest], - ~.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_experiment' not in self._stubs: - self._stubs['delete_experiment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Experiments/DeleteExperiment', - request_serializer=experiment.DeleteExperimentRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_experiment'] - - @property - def start_experiment(self) -> Callable[ - [experiment.StartExperimentRequest], - experiment.Experiment]: - r"""Return a callable for the start experiment method over gRPC. - - Starts the specified - [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. This rpc - only changes the state of experiment from PENDING to RUNNING. - - Returns: - Callable[[~.StartExperimentRequest], - ~.Experiment]: - 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 'start_experiment' not in self._stubs: - self._stubs['start_experiment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Experiments/StartExperiment', - request_serializer=experiment.StartExperimentRequest.serialize, - response_deserializer=experiment.Experiment.deserialize, - ) - return self._stubs['start_experiment'] - - @property - def stop_experiment(self) -> Callable[ - [experiment.StopExperimentRequest], - experiment.Experiment]: - r"""Return a callable for the stop experiment method over gRPC. - - Stops the specified - [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. This rpc - only changes the state of experiment from RUNNING to DONE. - - Returns: - Callable[[~.StopExperimentRequest], - ~.Experiment]: - 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 'stop_experiment' not in self._stubs: - self._stubs['stop_experiment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Experiments/StopExperiment', - request_serializer=experiment.StopExperimentRequest.serialize, - response_deserializer=experiment.Experiment.deserialize, - ) - return self._stubs['stop_experiment'] - - 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 list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'ExperimentsGrpcTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc_asyncio.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc_asyncio.py deleted file mode 100644 index fa58bfaf..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc_asyncio.py +++ /dev/null @@ -1,525 +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.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.dialogflowcx_v3.types import experiment -from google.cloud.dialogflowcx_v3.types import experiment as gcdc_experiment -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from .base import ExperimentsTransport, DEFAULT_CLIENT_INFO -from .grpc import ExperimentsGrpcTransport - - -class ExperimentsGrpcAsyncIOTransport(ExperimentsTransport): - """gRPC AsyncIO backend transport for Experiments. - - Service for managing - [Experiments][google.cloud.dialogflow.cx.v3.Experiment]. - - 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 = 'dialogflow.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 = 'dialogflow.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] = {} - - 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 list_experiments(self) -> Callable[ - [experiment.ListExperimentsRequest], - Awaitable[experiment.ListExperimentsResponse]]: - r"""Return a callable for the list experiments method over gRPC. - - Returns the list of all experiments in the specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - Returns: - Callable[[~.ListExperimentsRequest], - Awaitable[~.ListExperimentsResponse]]: - 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_experiments' not in self._stubs: - self._stubs['list_experiments'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Experiments/ListExperiments', - request_serializer=experiment.ListExperimentsRequest.serialize, - response_deserializer=experiment.ListExperimentsResponse.deserialize, - ) - return self._stubs['list_experiments'] - - @property - def get_experiment(self) -> Callable[ - [experiment.GetExperimentRequest], - Awaitable[experiment.Experiment]]: - r"""Return a callable for the get experiment method over gRPC. - - Retrieves the specified - [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. - - Returns: - Callable[[~.GetExperimentRequest], - Awaitable[~.Experiment]]: - 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_experiment' not in self._stubs: - self._stubs['get_experiment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Experiments/GetExperiment', - request_serializer=experiment.GetExperimentRequest.serialize, - response_deserializer=experiment.Experiment.deserialize, - ) - return self._stubs['get_experiment'] - - @property - def create_experiment(self) -> Callable[ - [gcdc_experiment.CreateExperimentRequest], - Awaitable[gcdc_experiment.Experiment]]: - r"""Return a callable for the create experiment method over gRPC. - - Creates an - [Experiment][google.cloud.dialogflow.cx.v3.Experiment] in the - specified - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - - Returns: - Callable[[~.CreateExperimentRequest], - Awaitable[~.Experiment]]: - 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_experiment' not in self._stubs: - self._stubs['create_experiment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Experiments/CreateExperiment', - request_serializer=gcdc_experiment.CreateExperimentRequest.serialize, - response_deserializer=gcdc_experiment.Experiment.deserialize, - ) - return self._stubs['create_experiment'] - - @property - def update_experiment(self) -> Callable[ - [gcdc_experiment.UpdateExperimentRequest], - Awaitable[gcdc_experiment.Experiment]]: - r"""Return a callable for the update experiment method over gRPC. - - Updates the specified - [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. - - Returns: - Callable[[~.UpdateExperimentRequest], - Awaitable[~.Experiment]]: - 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_experiment' not in self._stubs: - self._stubs['update_experiment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Experiments/UpdateExperiment', - request_serializer=gcdc_experiment.UpdateExperimentRequest.serialize, - response_deserializer=gcdc_experiment.Experiment.deserialize, - ) - return self._stubs['update_experiment'] - - @property - def delete_experiment(self) -> Callable[ - [experiment.DeleteExperimentRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete experiment method over gRPC. - - Deletes the specified - [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. - - Returns: - Callable[[~.DeleteExperimentRequest], - 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_experiment' not in self._stubs: - self._stubs['delete_experiment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Experiments/DeleteExperiment', - request_serializer=experiment.DeleteExperimentRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_experiment'] - - @property - def start_experiment(self) -> Callable[ - [experiment.StartExperimentRequest], - Awaitable[experiment.Experiment]]: - r"""Return a callable for the start experiment method over gRPC. - - Starts the specified - [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. This rpc - only changes the state of experiment from PENDING to RUNNING. - - Returns: - Callable[[~.StartExperimentRequest], - Awaitable[~.Experiment]]: - 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 'start_experiment' not in self._stubs: - self._stubs['start_experiment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Experiments/StartExperiment', - request_serializer=experiment.StartExperimentRequest.serialize, - response_deserializer=experiment.Experiment.deserialize, - ) - return self._stubs['start_experiment'] - - @property - def stop_experiment(self) -> Callable[ - [experiment.StopExperimentRequest], - Awaitable[experiment.Experiment]]: - r"""Return a callable for the stop experiment method over gRPC. - - Stops the specified - [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. This rpc - only changes the state of experiment from RUNNING to DONE. - - Returns: - Callable[[~.StopExperimentRequest], - Awaitable[~.Experiment]]: - 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 'stop_experiment' not in self._stubs: - self._stubs['stop_experiment'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Experiments/StopExperiment', - request_serializer=experiment.StopExperimentRequest.serialize, - response_deserializer=experiment.Experiment.deserialize, - ) - return self._stubs['stop_experiment'] - - 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"] - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - -__all__ = ( - 'ExperimentsGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/transports/rest.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/transports/rest.py deleted file mode 100644 index 1a1cf871..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/experiments/transports/rest.py +++ /dev/null @@ -1,1416 +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.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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.dialogflowcx_v3.types import experiment -from google.cloud.dialogflowcx_v3.types import experiment as gcdc_experiment -from google.protobuf import empty_pb2 # type: ignore - -from .base import ExperimentsTransport, 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 ExperimentsRestInterceptor: - """Interceptor for Experiments. - - 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 ExperimentsRestTransport. - - .. code-block:: python - class MyCustomExperimentsInterceptor(ExperimentsRestInterceptor): - def pre_create_experiment(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_experiment(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_experiment(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_get_experiment(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_experiment(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_experiments(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_experiments(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_start_experiment(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_start_experiment(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_stop_experiment(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_stop_experiment(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_experiment(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_experiment(self, response): - logging.log(f"Received response: {response}") - return response - - transport = ExperimentsRestTransport(interceptor=MyCustomExperimentsInterceptor()) - client = ExperimentsClient(transport=transport) - - - """ - def pre_create_experiment(self, request: gcdc_experiment.CreateExperimentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_experiment.CreateExperimentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_experiment - - Override in a subclass to manipulate the request or metadata - before they are sent to the Experiments server. - """ - return request, metadata - - def post_create_experiment(self, response: gcdc_experiment.Experiment) -> gcdc_experiment.Experiment: - """Post-rpc interceptor for create_experiment - - Override in a subclass to manipulate the response - after it is returned by the Experiments server but before - it is returned to user code. - """ - return response - def pre_delete_experiment(self, request: experiment.DeleteExperimentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[experiment.DeleteExperimentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_experiment - - Override in a subclass to manipulate the request or metadata - before they are sent to the Experiments server. - """ - return request, metadata - - def pre_get_experiment(self, request: experiment.GetExperimentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[experiment.GetExperimentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_experiment - - Override in a subclass to manipulate the request or metadata - before they are sent to the Experiments server. - """ - return request, metadata - - def post_get_experiment(self, response: experiment.Experiment) -> experiment.Experiment: - """Post-rpc interceptor for get_experiment - - Override in a subclass to manipulate the response - after it is returned by the Experiments server but before - it is returned to user code. - """ - return response - def pre_list_experiments(self, request: experiment.ListExperimentsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[experiment.ListExperimentsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_experiments - - Override in a subclass to manipulate the request or metadata - before they are sent to the Experiments server. - """ - return request, metadata - - def post_list_experiments(self, response: experiment.ListExperimentsResponse) -> experiment.ListExperimentsResponse: - """Post-rpc interceptor for list_experiments - - Override in a subclass to manipulate the response - after it is returned by the Experiments server but before - it is returned to user code. - """ - return response - def pre_start_experiment(self, request: experiment.StartExperimentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[experiment.StartExperimentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for start_experiment - - Override in a subclass to manipulate the request or metadata - before they are sent to the Experiments server. - """ - return request, metadata - - def post_start_experiment(self, response: experiment.Experiment) -> experiment.Experiment: - """Post-rpc interceptor for start_experiment - - Override in a subclass to manipulate the response - after it is returned by the Experiments server but before - it is returned to user code. - """ - return response - def pre_stop_experiment(self, request: experiment.StopExperimentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[experiment.StopExperimentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for stop_experiment - - Override in a subclass to manipulate the request or metadata - before they are sent to the Experiments server. - """ - return request, metadata - - def post_stop_experiment(self, response: experiment.Experiment) -> experiment.Experiment: - """Post-rpc interceptor for stop_experiment - - Override in a subclass to manipulate the response - after it is returned by the Experiments server but before - it is returned to user code. - """ - return response - def pre_update_experiment(self, request: gcdc_experiment.UpdateExperimentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_experiment.UpdateExperimentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_experiment - - Override in a subclass to manipulate the request or metadata - before they are sent to the Experiments server. - """ - return request, metadata - - def post_update_experiment(self, response: gcdc_experiment.Experiment) -> gcdc_experiment.Experiment: - """Post-rpc interceptor for update_experiment - - Override in a subclass to manipulate the response - after it is returned by the Experiments server but before - it is returned to user code. - """ - return response - - def pre_get_location( - self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_location - - Override in a subclass to manipulate the request or metadata - before they are sent to the Experiments server. - """ - return request, metadata - - def post_get_location( - self, response: locations_pb2.Location - ) -> locations_pb2.Location: - """Post-rpc interceptor for get_location - - Override in a subclass to manipulate the response - after it is returned by the Experiments server but before - it is returned to user code. - """ - return response - def pre_list_locations( - self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_locations - - Override in a subclass to manipulate the request or metadata - before they are sent to the Experiments server. - """ - return request, metadata - - def post_list_locations( - self, response: locations_pb2.ListLocationsResponse - ) -> locations_pb2.ListLocationsResponse: - """Post-rpc interceptor for list_locations - - Override in a subclass to manipulate the response - after it is returned by the Experiments 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 Experiments 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 Experiments 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 Experiments 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 Experiments 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 Experiments 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 Experiments server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class ExperimentsRestStub: - _session: AuthorizedSession - _host: str - _interceptor: ExperimentsRestInterceptor - - -class ExperimentsRestTransport(ExperimentsTransport): - """REST backend transport for Experiments. - - Service for managing - [Experiments][google.cloud.dialogflow.cx.v3.Experiment]. - - 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 = 'dialogflow.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[ExperimentsRestInterceptor] = 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) - if client_cert_source_for_mtls: - self._session.configure_mtls_channel(client_cert_source_for_mtls) - self._interceptor = interceptor or ExperimentsRestInterceptor() - self._prep_wrapped_messages(client_info) - - class _CreateExperiment(ExperimentsRestStub): - def __hash__(self): - return hash("CreateExperiment") - - __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: gcdc_experiment.CreateExperimentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_experiment.Experiment: - r"""Call the create experiment method over HTTP. - - Args: - request (~.gcdc_experiment.CreateExperimentRequest): - The request object. The request message for - [Experiments.CreateExperiment][google.cloud.dialogflow.cx.v3.Experiments.CreateExperiment]. - 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: - ~.gcdc_experiment.Experiment: - Represents an experiment in an - environment. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*/environments/*}/experiments', - 'body': 'experiment', - }, - ] - request, metadata = self._interceptor.pre_create_experiment(request, metadata) - pb_request = gcdc_experiment.CreateExperimentRequest.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 = gcdc_experiment.Experiment() - pb_resp = gcdc_experiment.Experiment.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_experiment(resp) - return resp - - class _DeleteExperiment(ExperimentsRestStub): - def __hash__(self): - return hash("DeleteExperiment") - - __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: experiment.DeleteExperimentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete experiment method over HTTP. - - Args: - request (~.experiment.DeleteExperimentRequest): - The request object. The request message for - [Experiments.DeleteExperiment][google.cloud.dialogflow.cx.v3.Experiments.DeleteExperiment]. - 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': '/v3/{name=projects/*/locations/*/agents/*/environments/*/experiments/*}', - }, - ] - request, metadata = self._interceptor.pre_delete_experiment(request, metadata) - pb_request = experiment.DeleteExperimentRequest.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 _GetExperiment(ExperimentsRestStub): - def __hash__(self): - return hash("GetExperiment") - - __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: experiment.GetExperimentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> experiment.Experiment: - r"""Call the get experiment method over HTTP. - - Args: - request (~.experiment.GetExperimentRequest): - The request object. The request message for - [Experiments.GetExperiment][google.cloud.dialogflow.cx.v3.Experiments.GetExperiment]. - 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: - ~.experiment.Experiment: - Represents an experiment in an - environment. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/environments/*/experiments/*}', - }, - ] - request, metadata = self._interceptor.pre_get_experiment(request, metadata) - pb_request = experiment.GetExperimentRequest.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 = experiment.Experiment() - pb_resp = experiment.Experiment.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_experiment(resp) - return resp - - class _ListExperiments(ExperimentsRestStub): - def __hash__(self): - return hash("ListExperiments") - - __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: experiment.ListExperimentsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> experiment.ListExperimentsResponse: - r"""Call the list experiments method over HTTP. - - Args: - request (~.experiment.ListExperimentsRequest): - The request object. The request message for - [Experiments.ListExperiments][google.cloud.dialogflow.cx.v3.Experiments.ListExperiments]. - 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: - ~.experiment.ListExperimentsResponse: - The response message for - [Experiments.ListExperiments][google.cloud.dialogflow.cx.v3.Experiments.ListExperiments]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*/environments/*}/experiments', - }, - ] - request, metadata = self._interceptor.pre_list_experiments(request, metadata) - pb_request = experiment.ListExperimentsRequest.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 = experiment.ListExperimentsResponse() - pb_resp = experiment.ListExperimentsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_experiments(resp) - return resp - - class _StartExperiment(ExperimentsRestStub): - def __hash__(self): - return hash("StartExperiment") - - __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: experiment.StartExperimentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> experiment.Experiment: - r"""Call the start experiment method over HTTP. - - Args: - request (~.experiment.StartExperimentRequest): - The request object. The request message for - [Experiments.StartExperiment][google.cloud.dialogflow.cx.v3.Experiments.StartExperiment]. - 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: - ~.experiment.Experiment: - Represents an experiment in an - environment. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/environments/*/experiments/*}:start', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_start_experiment(request, metadata) - pb_request = experiment.StartExperimentRequest.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 = experiment.Experiment() - pb_resp = experiment.Experiment.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_start_experiment(resp) - return resp - - class _StopExperiment(ExperimentsRestStub): - def __hash__(self): - return hash("StopExperiment") - - __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: experiment.StopExperimentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> experiment.Experiment: - r"""Call the stop experiment method over HTTP. - - Args: - request (~.experiment.StopExperimentRequest): - The request object. The request message for - [Experiments.StopExperiment][google.cloud.dialogflow.cx.v3.Experiments.StopExperiment]. - 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: - ~.experiment.Experiment: - Represents an experiment in an - environment. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/environments/*/experiments/*}:stop', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_stop_experiment(request, metadata) - pb_request = experiment.StopExperimentRequest.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 = experiment.Experiment() - pb_resp = experiment.Experiment.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_stop_experiment(resp) - return resp - - class _UpdateExperiment(ExperimentsRestStub): - def __hash__(self): - return hash("UpdateExperiment") - - __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: gcdc_experiment.UpdateExperimentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_experiment.Experiment: - r"""Call the update experiment method over HTTP. - - Args: - request (~.gcdc_experiment.UpdateExperimentRequest): - The request object. The request message for - [Experiments.UpdateExperiment][google.cloud.dialogflow.cx.v3.Experiments.UpdateExperiment]. - 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: - ~.gcdc_experiment.Experiment: - Represents an experiment in an - environment. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v3/{experiment.name=projects/*/locations/*/agents/*/environments/*/experiments/*}', - 'body': 'experiment', - }, - ] - request, metadata = self._interceptor.pre_update_experiment(request, metadata) - pb_request = gcdc_experiment.UpdateExperimentRequest.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 = gcdc_experiment.Experiment() - pb_resp = gcdc_experiment.Experiment.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_experiment(resp) - return resp - - @property - def create_experiment(self) -> Callable[ - [gcdc_experiment.CreateExperimentRequest], - gcdc_experiment.Experiment]: - # 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._CreateExperiment(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_experiment(self) -> Callable[ - [experiment.DeleteExperimentRequest], - 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._DeleteExperiment(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_experiment(self) -> Callable[ - [experiment.GetExperimentRequest], - experiment.Experiment]: - # 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._GetExperiment(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_experiments(self) -> Callable[ - [experiment.ListExperimentsRequest], - experiment.ListExperimentsResponse]: - # 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._ListExperiments(self._session, self._host, self._interceptor) # type: ignore - - @property - def start_experiment(self) -> Callable[ - [experiment.StartExperimentRequest], - experiment.Experiment]: - # 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._StartExperiment(self._session, self._host, self._interceptor) # type: ignore - - @property - def stop_experiment(self) -> Callable[ - [experiment.StopExperimentRequest], - experiment.Experiment]: - # 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._StopExperiment(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_experiment(self) -> Callable[ - [gcdc_experiment.UpdateExperimentRequest], - gcdc_experiment.Experiment]: - # 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._UpdateExperiment(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_location(self): - return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore - - class _GetLocation(ExperimentsRestStub): - def __call__(self, - request: locations_pb2.GetLocationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.Location: - - r"""Call the get location method over HTTP. - - Args: - request (locations_pb2.GetLocationRequest): - The request object for GetLocation 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: - locations_pb2.Location: Response from GetLocation method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*}', - }, - ] - - request, metadata = self._interceptor.pre_get_location(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 = locations_pb2.Location() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_get_location(resp) - return resp - - @property - def list_locations(self): - return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore - - class _ListLocations(ExperimentsRestStub): - def __call__(self, - request: locations_pb2.ListLocationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.ListLocationsResponse: - - r"""Call the list locations method over HTTP. - - Args: - request (locations_pb2.ListLocationsRequest): - The request object for ListLocations 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: - locations_pb2.ListLocationsResponse: Response from ListLocations method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*}/locations', - }, - ] - - request, metadata = self._interceptor.pre_list_locations(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 = locations_pb2.ListLocationsResponse() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_list_locations(resp) - return resp - - @property - def cancel_operation(self): - return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore - - class _CancelOperation(ExperimentsRestStub): - 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': '/v3/{name=projects/*/operations/*}:cancel', - }, -{ - 'method': 'post', - 'uri': '/v3/{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(ExperimentsRestStub): - 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': '/v3/{name=projects/*/operations/*}', - }, -{ - 'method': 'get', - 'uri': '/v3/{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(ExperimentsRestStub): - 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': '/v3/{name=projects/*}/operations', - }, -{ - 'method': 'get', - 'uri': '/v3/{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__=( - 'ExperimentsRestTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/__init__.py deleted file mode 100644 index 420f8808..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/__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 FlowsClient -from .async_client import FlowsAsyncClient - -__all__ = ( - 'FlowsClient', - 'FlowsAsyncClient', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/async_client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/async_client.py deleted file mode 100644 index 7a3bf8e5..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/async_client.py +++ /dev/null @@ -1,1617 +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.dialogflowcx_v3 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.dialogflowcx_v3.services.flows import pagers -from google.cloud.dialogflowcx_v3.types import flow -from google.cloud.dialogflowcx_v3.types import flow as gcdc_flow -from google.cloud.dialogflowcx_v3.types import page -from google.cloud.dialogflowcx_v3.types import validation_message -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import struct_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import FlowsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import FlowsGrpcAsyncIOTransport -from .client import FlowsClient - - -class FlowsAsyncClient: - """Service for managing [Flows][google.cloud.dialogflow.cx.v3.Flow].""" - - _client: FlowsClient - - DEFAULT_ENDPOINT = FlowsClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = FlowsClient.DEFAULT_MTLS_ENDPOINT - - flow_path = staticmethod(FlowsClient.flow_path) - parse_flow_path = staticmethod(FlowsClient.parse_flow_path) - flow_validation_result_path = staticmethod(FlowsClient.flow_validation_result_path) - parse_flow_validation_result_path = staticmethod(FlowsClient.parse_flow_validation_result_path) - intent_path = staticmethod(FlowsClient.intent_path) - parse_intent_path = staticmethod(FlowsClient.parse_intent_path) - page_path = staticmethod(FlowsClient.page_path) - parse_page_path = staticmethod(FlowsClient.parse_page_path) - transition_route_group_path = staticmethod(FlowsClient.transition_route_group_path) - parse_transition_route_group_path = staticmethod(FlowsClient.parse_transition_route_group_path) - webhook_path = staticmethod(FlowsClient.webhook_path) - parse_webhook_path = staticmethod(FlowsClient.parse_webhook_path) - common_billing_account_path = staticmethod(FlowsClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(FlowsClient.parse_common_billing_account_path) - common_folder_path = staticmethod(FlowsClient.common_folder_path) - parse_common_folder_path = staticmethod(FlowsClient.parse_common_folder_path) - common_organization_path = staticmethod(FlowsClient.common_organization_path) - parse_common_organization_path = staticmethod(FlowsClient.parse_common_organization_path) - common_project_path = staticmethod(FlowsClient.common_project_path) - parse_common_project_path = staticmethod(FlowsClient.parse_common_project_path) - common_location_path = staticmethod(FlowsClient.common_location_path) - parse_common_location_path = staticmethod(FlowsClient.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: - FlowsAsyncClient: The constructed client. - """ - return FlowsClient.from_service_account_info.__func__(FlowsAsyncClient, 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: - FlowsAsyncClient: The constructed client. - """ - return FlowsClient.from_service_account_file.__func__(FlowsAsyncClient, 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 FlowsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> FlowsTransport: - """Returns the transport used by the client instance. - - Returns: - FlowsTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(FlowsClient).get_transport_class, type(FlowsClient)) - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, FlowsTransport] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the flows 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, ~.FlowsTransport]): 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 = FlowsClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def create_flow(self, - request: Optional[Union[gcdc_flow.CreateFlowRequest, dict]] = None, - *, - parent: Optional[str] = None, - flow: Optional[gcdc_flow.Flow] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_flow.Flow: - r"""Creates a flow in the specified agent. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - async def sample_create_flow(): - # Create a client - client = dialogflowcx_v3.FlowsAsyncClient() - - # Initialize request argument(s) - flow = dialogflowcx_v3.Flow() - flow.display_name = "display_name_value" - - request = dialogflowcx_v3.CreateFlowRequest( - parent="parent_value", - flow=flow, - ) - - # Make the request - response = await client.create_flow(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.CreateFlowRequest, dict]]): - The request object. The request message for - [Flows.CreateFlow][google.cloud.dialogflow.cx.v3.Flows.CreateFlow]. - parent (:class:`str`): - Required. The agent to create a flow for. Format: - ``projects//locations//agents/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - flow (:class:`google.cloud.dialogflowcx_v3.types.Flow`): - Required. The flow to create. - This corresponds to the ``flow`` 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.dialogflowcx_v3.types.Flow: - Flows represents the conversation - flows when you build your chatbot agent. - A flow consists of many pages connected - by the transition routes. Conversations - always start with the built-in Start - Flow (with an all-0 ID). Transition - routes can direct the conversation - session from the current flow (parent - flow) to another flow (sub flow). When - the sub flow is finished, Dialogflow - will bring the session back to the - parent flow, where the sub flow is - started. - - Usually, when a transition route is - followed by a matched intent, the intent - will be "consumed". This means the - intent won't activate more transition - routes. However, when the followed - transition route moves the conversation - session into a different flow, the - matched intent can be carried over and - to be consumed in the target flow. - - """ - # 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, flow]) - 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 = gcdc_flow.CreateFlowRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if flow is not None: - request.flow = flow - - # 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_flow, - 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_flow(self, - request: Optional[Union[flow.DeleteFlowRequest, 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 specified flow. - - .. 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 dialogflowcx_v3 - - async def sample_delete_flow(): - # Create a client - client = dialogflowcx_v3.FlowsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteFlowRequest( - name="name_value", - ) - - # Make the request - await client.delete_flow(request=request) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.DeleteFlowRequest, dict]]): - The request object. The request message for - [Flows.DeleteFlow][google.cloud.dialogflow.cx.v3.Flows.DeleteFlow]. - name (:class:`str`): - Required. The name of the flow to delete. Format: - ``projects//locations//agents//flows/``. - - 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 = flow.DeleteFlowRequest(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_flow, - 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_flows(self, - request: Optional[Union[flow.ListFlowsRequest, 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.ListFlowsAsyncPager: - r"""Returns the list of all flows in the specified agent. - - .. 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 dialogflowcx_v3 - - async def sample_list_flows(): - # Create a client - client = dialogflowcx_v3.FlowsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListFlowsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_flows(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ListFlowsRequest, dict]]): - The request object. The request message for - [Flows.ListFlows][google.cloud.dialogflow.cx.v3.Flows.ListFlows]. - parent (:class:`str`): - Required. The agent containing the flows. Format: - ``projects//locations//agents/``. - - 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.dialogflowcx_v3.services.flows.pagers.ListFlowsAsyncPager: - The response message for - [Flows.ListFlows][google.cloud.dialogflow.cx.v3.Flows.ListFlows]. - - 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 = flow.ListFlowsRequest(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_flows, - 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.ListFlowsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_flow(self, - request: Optional[Union[flow.GetFlowRequest, 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]] = (), - ) -> flow.Flow: - r"""Retrieves the specified flow. - - .. 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 dialogflowcx_v3 - - async def sample_get_flow(): - # Create a client - client = dialogflowcx_v3.FlowsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetFlowRequest( - name="name_value", - ) - - # Make the request - response = await client.get_flow(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.GetFlowRequest, dict]]): - The request object. The response message for - [Flows.GetFlow][google.cloud.dialogflow.cx.v3.Flows.GetFlow]. - name (:class:`str`): - Required. The name of the flow to get. Format: - ``projects//locations//agents//flows/``. - - 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.dialogflowcx_v3.types.Flow: - Flows represents the conversation - flows when you build your chatbot agent. - A flow consists of many pages connected - by the transition routes. Conversations - always start with the built-in Start - Flow (with an all-0 ID). Transition - routes can direct the conversation - session from the current flow (parent - flow) to another flow (sub flow). When - the sub flow is finished, Dialogflow - will bring the session back to the - parent flow, where the sub flow is - started. - - Usually, when a transition route is - followed by a matched intent, the intent - will be "consumed". This means the - intent won't activate more transition - routes. However, when the followed - transition route moves the conversation - session into a different flow, the - matched intent can be carried over and - to be consumed in the target flow. - - """ - # 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 = flow.GetFlowRequest(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_flow, - 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_flow(self, - request: Optional[Union[gcdc_flow.UpdateFlowRequest, dict]] = None, - *, - flow: Optional[gcdc_flow.Flow] = 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]] = (), - ) -> gcdc_flow.Flow: - r"""Updates the specified flow. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - async def sample_update_flow(): - # Create a client - client = dialogflowcx_v3.FlowsAsyncClient() - - # Initialize request argument(s) - flow = dialogflowcx_v3.Flow() - flow.display_name = "display_name_value" - - request = dialogflowcx_v3.UpdateFlowRequest( - flow=flow, - ) - - # Make the request - response = await client.update_flow(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.UpdateFlowRequest, dict]]): - The request object. The request message for - [Flows.UpdateFlow][google.cloud.dialogflow.cx.v3.Flows.UpdateFlow]. - flow (:class:`google.cloud.dialogflowcx_v3.types.Flow`): - Required. The flow to update. - This corresponds to the ``flow`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The mask to control which fields get - updated. If the mask is not present, all - fields will 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.dialogflowcx_v3.types.Flow: - Flows represents the conversation - flows when you build your chatbot agent. - A flow consists of many pages connected - by the transition routes. Conversations - always start with the built-in Start - Flow (with an all-0 ID). Transition - routes can direct the conversation - session from the current flow (parent - flow) to another flow (sub flow). When - the sub flow is finished, Dialogflow - will bring the session back to the - parent flow, where the sub flow is - started. - - Usually, when a transition route is - followed by a matched intent, the intent - will be "consumed". This means the - intent won't activate more transition - routes. However, when the followed - transition route moves the conversation - session into a different flow, the - matched intent can be carried over and - to be consumed in the target flow. - - """ - # 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([flow, 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 = gcdc_flow.UpdateFlowRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if flow is not None: - request.flow = flow - 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_flow, - 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(( - ("flow.name", request.flow.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def train_flow(self, - request: Optional[Union[flow.TrainFlowRequest, 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"""Trains the specified flow. Note that only the flow in 'draft' - environment is trained. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: An `Empty - message `__ - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - async def sample_train_flow(): - # Create a client - client = dialogflowcx_v3.FlowsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.TrainFlowRequest( - name="name_value", - ) - - # Make the request - operation = client.train_flow(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.TrainFlowRequest, dict]]): - The request object. The request message for - [Flows.TrainFlow][google.cloud.dialogflow.cx.v3.Flows.TrainFlow]. - name (:class:`str`): - Required. The flow to train. Format: - ``projects//locations//agents//flows/``. - - 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 = flow.TrainFlowRequest(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.train_flow, - 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=struct_pb2.Struct, - ) - - # Done; return the response. - return response - - async def validate_flow(self, - request: Optional[Union[flow.ValidateFlowRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> flow.FlowValidationResult: - r"""Validates the specified flow and creates or updates - validation results. Please call this API after the - training is completed to get the complete validation - results. - - .. 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 dialogflowcx_v3 - - async def sample_validate_flow(): - # Create a client - client = dialogflowcx_v3.FlowsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ValidateFlowRequest( - name="name_value", - ) - - # Make the request - response = await client.validate_flow(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ValidateFlowRequest, dict]]): - The request object. The request message for - [Flows.ValidateFlow][google.cloud.dialogflow.cx.v3.Flows.ValidateFlow]. - 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.dialogflowcx_v3.types.FlowValidationResult: - The response message for - [Flows.GetFlowValidationResult][google.cloud.dialogflow.cx.v3.Flows.GetFlowValidationResult]. - - """ - # Create or coerce a protobuf request object. - request = flow.ValidateFlowRequest(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.validate_flow, - 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_flow_validation_result(self, - request: Optional[Union[flow.GetFlowValidationResultRequest, 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]] = (), - ) -> flow.FlowValidationResult: - r"""Gets the latest flow validation result. Flow - validation is performed when ValidateFlow is called. - - .. 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 dialogflowcx_v3 - - async def sample_get_flow_validation_result(): - # Create a client - client = dialogflowcx_v3.FlowsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetFlowValidationResultRequest( - name="name_value", - ) - - # Make the request - response = await client.get_flow_validation_result(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.GetFlowValidationResultRequest, dict]]): - The request object. The request message for - [Flows.GetFlowValidationResult][google.cloud.dialogflow.cx.v3.Flows.GetFlowValidationResult]. - name (:class:`str`): - Required. The flow name. Format: - ``projects//locations//agents//flows//validationResult``. - - 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.dialogflowcx_v3.types.FlowValidationResult: - The response message for - [Flows.GetFlowValidationResult][google.cloud.dialogflow.cx.v3.Flows.GetFlowValidationResult]. - - """ - # 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 = flow.GetFlowValidationResultRequest(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_flow_validation_result, - 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 import_flow(self, - request: Optional[Union[flow.ImportFlowRequest, 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"""Imports the specified flow to the specified agent from a binary - file. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: - [ImportFlowResponse][google.cloud.dialogflow.cx.v3.ImportFlowResponse] - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - async def sample_import_flow(): - # Create a client - client = dialogflowcx_v3.FlowsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ImportFlowRequest( - flow_uri="flow_uri_value", - parent="parent_value", - ) - - # Make the request - operation = client.import_flow(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ImportFlowRequest, dict]]): - The request object. The request message for - [Flows.ImportFlow][google.cloud.dialogflow.cx.v3.Flows.ImportFlow]. - 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.dialogflowcx_v3.types.ImportFlowResponse` The response message for - [Flows.ImportFlow][google.cloud.dialogflow.cx.v3.Flows.ImportFlow]. - - """ - # Create or coerce a protobuf request object. - request = flow.ImportFlowRequest(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.import_flow, - 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, - flow.ImportFlowResponse, - metadata_type=struct_pb2.Struct, - ) - - # Done; return the response. - return response - - async def export_flow(self, - request: Optional[Union[flow.ExportFlowRequest, 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"""Exports the specified flow to a binary file. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: - [ExportFlowResponse][google.cloud.dialogflow.cx.v3.ExportFlowResponse] - - Note that resources (e.g. intents, entities, webhooks) that the - flow references will also be exported. - - .. 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 dialogflowcx_v3 - - async def sample_export_flow(): - # Create a client - client = dialogflowcx_v3.FlowsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ExportFlowRequest( - name="name_value", - ) - - # Make the request - operation = client.export_flow(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ExportFlowRequest, dict]]): - The request object. The request message for - [Flows.ExportFlow][google.cloud.dialogflow.cx.v3.Flows.ExportFlow]. - 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.dialogflowcx_v3.types.ExportFlowResponse` The response message for - [Flows.ExportFlow][google.cloud.dialogflow.cx.v3.Flows.ExportFlow]. - - """ - # Create or coerce a protobuf request object. - request = flow.ExportFlowRequest(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.export_flow, - 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, - flow.ExportFlowResponse, - metadata_type=struct_pb2.Struct, - ) - - # Done; return the response. - return response - - 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 get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**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_location, - 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_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**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_locations, - 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 __aenter__(self) -> "FlowsAsyncClient": - 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__ = ( - "FlowsAsyncClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/client.py deleted file mode 100644 index 65b2164e..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/client.py +++ /dev/null @@ -1,1864 +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.dialogflowcx_v3 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.dialogflowcx_v3.services.flows import pagers -from google.cloud.dialogflowcx_v3.types import flow -from google.cloud.dialogflowcx_v3.types import flow as gcdc_flow -from google.cloud.dialogflowcx_v3.types import page -from google.cloud.dialogflowcx_v3.types import validation_message -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import struct_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import FlowsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import FlowsGrpcTransport -from .transports.grpc_asyncio import FlowsGrpcAsyncIOTransport -from .transports.rest import FlowsRestTransport - - -class FlowsClientMeta(type): - """Metaclass for the Flows 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[FlowsTransport]] - _transport_registry["grpc"] = FlowsGrpcTransport - _transport_registry["grpc_asyncio"] = FlowsGrpcAsyncIOTransport - _transport_registry["rest"] = FlowsRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[FlowsTransport]: - """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 FlowsClient(metaclass=FlowsClientMeta): - """Service for managing [Flows][google.cloud.dialogflow.cx.v3.Flow].""" - - @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 = "dialogflow.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: - FlowsClient: 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: - FlowsClient: 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) -> FlowsTransport: - """Returns the transport used by the client instance. - - Returns: - FlowsTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def flow_path(project: str,location: str,agent: str,flow: str,) -> str: - """Returns a fully-qualified flow string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}".format(project=project, location=location, agent=agent, flow=flow, ) - - @staticmethod - def parse_flow_path(path: str) -> Dict[str,str]: - """Parses a flow path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def flow_validation_result_path(project: str,location: str,agent: str,flow: str,) -> str: - """Returns a fully-qualified flow_validation_result string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/validationResult".format(project=project, location=location, agent=agent, flow=flow, ) - - @staticmethod - def parse_flow_validation_result_path(path: str) -> Dict[str,str]: - """Parses a flow_validation_result path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)/validationResult$", path) - return m.groupdict() if m else {} - - @staticmethod - def intent_path(project: str,location: str,agent: str,intent: str,) -> str: - """Returns a fully-qualified intent string.""" - return "projects/{project}/locations/{location}/agents/{agent}/intents/{intent}".format(project=project, location=location, agent=agent, intent=intent, ) - - @staticmethod - def parse_intent_path(path: str) -> Dict[str,str]: - """Parses a intent path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/intents/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def page_path(project: str,location: str,agent: str,flow: str,page: str,) -> str: - """Returns a fully-qualified page string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page}".format(project=project, location=location, agent=agent, flow=flow, page=page, ) - - @staticmethod - def parse_page_path(path: str) -> Dict[str,str]: - """Parses a page path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)/pages/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def transition_route_group_path(project: str,location: str,agent: str,flow: str,transition_route_group: str,) -> str: - """Returns a fully-qualified transition_route_group string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}".format(project=project, location=location, agent=agent, flow=flow, transition_route_group=transition_route_group, ) - - @staticmethod - def parse_transition_route_group_path(path: str) -> Dict[str,str]: - """Parses a transition_route_group path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)/transitionRouteGroups/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def webhook_path(project: str,location: str,agent: str,webhook: str,) -> str: - """Returns a fully-qualified webhook string.""" - return "projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}".format(project=project, location=location, agent=agent, webhook=webhook, ) - - @staticmethod - def parse_webhook_path(path: str) -> Dict[str,str]: - """Parses a webhook path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/webhooks/(?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, FlowsTransport]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the flows 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, FlowsTransport]): 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, FlowsTransport): - # transport is a FlowsTransport 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_flow(self, - request: Optional[Union[gcdc_flow.CreateFlowRequest, dict]] = None, - *, - parent: Optional[str] = None, - flow: Optional[gcdc_flow.Flow] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_flow.Flow: - r"""Creates a flow in the specified agent. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - def sample_create_flow(): - # Create a client - client = dialogflowcx_v3.FlowsClient() - - # Initialize request argument(s) - flow = dialogflowcx_v3.Flow() - flow.display_name = "display_name_value" - - request = dialogflowcx_v3.CreateFlowRequest( - parent="parent_value", - flow=flow, - ) - - # Make the request - response = client.create_flow(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.CreateFlowRequest, dict]): - The request object. The request message for - [Flows.CreateFlow][google.cloud.dialogflow.cx.v3.Flows.CreateFlow]. - parent (str): - Required. The agent to create a flow for. Format: - ``projects//locations//agents/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - flow (google.cloud.dialogflowcx_v3.types.Flow): - Required. The flow to create. - This corresponds to the ``flow`` 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.dialogflowcx_v3.types.Flow: - Flows represents the conversation - flows when you build your chatbot agent. - A flow consists of many pages connected - by the transition routes. Conversations - always start with the built-in Start - Flow (with an all-0 ID). Transition - routes can direct the conversation - session from the current flow (parent - flow) to another flow (sub flow). When - the sub flow is finished, Dialogflow - will bring the session back to the - parent flow, where the sub flow is - started. - - Usually, when a transition route is - followed by a matched intent, the intent - will be "consumed". This means the - intent won't activate more transition - routes. However, when the followed - transition route moves the conversation - session into a different flow, the - matched intent can be carried over and - to be consumed in the target flow. - - """ - # 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, flow]) - 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 gcdc_flow.CreateFlowRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_flow.CreateFlowRequest): - request = gcdc_flow.CreateFlowRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if flow is not None: - request.flow = flow - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_flow] - - # 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_flow(self, - request: Optional[Union[flow.DeleteFlowRequest, 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 specified flow. - - .. 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 dialogflowcx_v3 - - def sample_delete_flow(): - # Create a client - client = dialogflowcx_v3.FlowsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteFlowRequest( - name="name_value", - ) - - # Make the request - client.delete_flow(request=request) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.DeleteFlowRequest, dict]): - The request object. The request message for - [Flows.DeleteFlow][google.cloud.dialogflow.cx.v3.Flows.DeleteFlow]. - name (str): - Required. The name of the flow to delete. Format: - ``projects//locations//agents//flows/``. - - 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 flow.DeleteFlowRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, flow.DeleteFlowRequest): - request = flow.DeleteFlowRequest(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_flow] - - # 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 list_flows(self, - request: Optional[Union[flow.ListFlowsRequest, 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.ListFlowsPager: - r"""Returns the list of all flows in the specified agent. - - .. 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 dialogflowcx_v3 - - def sample_list_flows(): - # Create a client - client = dialogflowcx_v3.FlowsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListFlowsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_flows(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ListFlowsRequest, dict]): - The request object. The request message for - [Flows.ListFlows][google.cloud.dialogflow.cx.v3.Flows.ListFlows]. - parent (str): - Required. The agent containing the flows. Format: - ``projects//locations//agents/``. - - 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.dialogflowcx_v3.services.flows.pagers.ListFlowsPager: - The response message for - [Flows.ListFlows][google.cloud.dialogflow.cx.v3.Flows.ListFlows]. - - 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 flow.ListFlowsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, flow.ListFlowsRequest): - request = flow.ListFlowsRequest(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_flows] - - # 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.ListFlowsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_flow(self, - request: Optional[Union[flow.GetFlowRequest, 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]] = (), - ) -> flow.Flow: - r"""Retrieves the specified flow. - - .. 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 dialogflowcx_v3 - - def sample_get_flow(): - # Create a client - client = dialogflowcx_v3.FlowsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetFlowRequest( - name="name_value", - ) - - # Make the request - response = client.get_flow(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.GetFlowRequest, dict]): - The request object. The response message for - [Flows.GetFlow][google.cloud.dialogflow.cx.v3.Flows.GetFlow]. - name (str): - Required. The name of the flow to get. Format: - ``projects//locations//agents//flows/``. - - 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.dialogflowcx_v3.types.Flow: - Flows represents the conversation - flows when you build your chatbot agent. - A flow consists of many pages connected - by the transition routes. Conversations - always start with the built-in Start - Flow (with an all-0 ID). Transition - routes can direct the conversation - session from the current flow (parent - flow) to another flow (sub flow). When - the sub flow is finished, Dialogflow - will bring the session back to the - parent flow, where the sub flow is - started. - - Usually, when a transition route is - followed by a matched intent, the intent - will be "consumed". This means the - intent won't activate more transition - routes. However, when the followed - transition route moves the conversation - session into a different flow, the - matched intent can be carried over and - to be consumed in the target flow. - - """ - # 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 flow.GetFlowRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, flow.GetFlowRequest): - request = flow.GetFlowRequest(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_flow] - - # 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_flow(self, - request: Optional[Union[gcdc_flow.UpdateFlowRequest, dict]] = None, - *, - flow: Optional[gcdc_flow.Flow] = 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]] = (), - ) -> gcdc_flow.Flow: - r"""Updates the specified flow. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - def sample_update_flow(): - # Create a client - client = dialogflowcx_v3.FlowsClient() - - # Initialize request argument(s) - flow = dialogflowcx_v3.Flow() - flow.display_name = "display_name_value" - - request = dialogflowcx_v3.UpdateFlowRequest( - flow=flow, - ) - - # Make the request - response = client.update_flow(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.UpdateFlowRequest, dict]): - The request object. The request message for - [Flows.UpdateFlow][google.cloud.dialogflow.cx.v3.Flows.UpdateFlow]. - flow (google.cloud.dialogflowcx_v3.types.Flow): - Required. The flow to update. - This corresponds to the ``flow`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The mask to control which fields get - updated. If the mask is not present, all - fields will 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.dialogflowcx_v3.types.Flow: - Flows represents the conversation - flows when you build your chatbot agent. - A flow consists of many pages connected - by the transition routes. Conversations - always start with the built-in Start - Flow (with an all-0 ID). Transition - routes can direct the conversation - session from the current flow (parent - flow) to another flow (sub flow). When - the sub flow is finished, Dialogflow - will bring the session back to the - parent flow, where the sub flow is - started. - - Usually, when a transition route is - followed by a matched intent, the intent - will be "consumed". This means the - intent won't activate more transition - routes. However, when the followed - transition route moves the conversation - session into a different flow, the - matched intent can be carried over and - to be consumed in the target flow. - - """ - # 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([flow, 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 gcdc_flow.UpdateFlowRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_flow.UpdateFlowRequest): - request = gcdc_flow.UpdateFlowRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if flow is not None: - request.flow = flow - 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_flow] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("flow.name", request.flow.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def train_flow(self, - request: Optional[Union[flow.TrainFlowRequest, 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"""Trains the specified flow. Note that only the flow in 'draft' - environment is trained. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: An `Empty - message `__ - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - def sample_train_flow(): - # Create a client - client = dialogflowcx_v3.FlowsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.TrainFlowRequest( - name="name_value", - ) - - # Make the request - operation = client.train_flow(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.TrainFlowRequest, dict]): - The request object. The request message for - [Flows.TrainFlow][google.cloud.dialogflow.cx.v3.Flows.TrainFlow]. - name (str): - Required. The flow to train. Format: - ``projects//locations//agents//flows/``. - - 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 flow.TrainFlowRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, flow.TrainFlowRequest): - request = flow.TrainFlowRequest(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.train_flow] - - # 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=struct_pb2.Struct, - ) - - # Done; return the response. - return response - - def validate_flow(self, - request: Optional[Union[flow.ValidateFlowRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> flow.FlowValidationResult: - r"""Validates the specified flow and creates or updates - validation results. Please call this API after the - training is completed to get the complete validation - results. - - .. 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 dialogflowcx_v3 - - def sample_validate_flow(): - # Create a client - client = dialogflowcx_v3.FlowsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ValidateFlowRequest( - name="name_value", - ) - - # Make the request - response = client.validate_flow(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ValidateFlowRequest, dict]): - The request object. The request message for - [Flows.ValidateFlow][google.cloud.dialogflow.cx.v3.Flows.ValidateFlow]. - 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.dialogflowcx_v3.types.FlowValidationResult: - The response message for - [Flows.GetFlowValidationResult][google.cloud.dialogflow.cx.v3.Flows.GetFlowValidationResult]. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a flow.ValidateFlowRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, flow.ValidateFlowRequest): - request = flow.ValidateFlowRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.validate_flow] - - # 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_flow_validation_result(self, - request: Optional[Union[flow.GetFlowValidationResultRequest, 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]] = (), - ) -> flow.FlowValidationResult: - r"""Gets the latest flow validation result. Flow - validation is performed when ValidateFlow is called. - - .. 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 dialogflowcx_v3 - - def sample_get_flow_validation_result(): - # Create a client - client = dialogflowcx_v3.FlowsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetFlowValidationResultRequest( - name="name_value", - ) - - # Make the request - response = client.get_flow_validation_result(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.GetFlowValidationResultRequest, dict]): - The request object. The request message for - [Flows.GetFlowValidationResult][google.cloud.dialogflow.cx.v3.Flows.GetFlowValidationResult]. - name (str): - Required. The flow name. Format: - ``projects//locations//agents//flows//validationResult``. - - 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.dialogflowcx_v3.types.FlowValidationResult: - The response message for - [Flows.GetFlowValidationResult][google.cloud.dialogflow.cx.v3.Flows.GetFlowValidationResult]. - - """ - # 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 flow.GetFlowValidationResultRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, flow.GetFlowValidationResultRequest): - request = flow.GetFlowValidationResultRequest(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_flow_validation_result] - - # 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 import_flow(self, - request: Optional[Union[flow.ImportFlowRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Imports the specified flow to the specified agent from a binary - file. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: - [ImportFlowResponse][google.cloud.dialogflow.cx.v3.ImportFlowResponse] - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - def sample_import_flow(): - # Create a client - client = dialogflowcx_v3.FlowsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ImportFlowRequest( - flow_uri="flow_uri_value", - parent="parent_value", - ) - - # Make the request - operation = client.import_flow(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ImportFlowRequest, dict]): - The request object. The request message for - [Flows.ImportFlow][google.cloud.dialogflow.cx.v3.Flows.ImportFlow]. - 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.dialogflowcx_v3.types.ImportFlowResponse` The response message for - [Flows.ImportFlow][google.cloud.dialogflow.cx.v3.Flows.ImportFlow]. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a flow.ImportFlowRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, flow.ImportFlowRequest): - request = flow.ImportFlowRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.import_flow] - - # 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, - flow.ImportFlowResponse, - metadata_type=struct_pb2.Struct, - ) - - # Done; return the response. - return response - - def export_flow(self, - request: Optional[Union[flow.ExportFlowRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Exports the specified flow to a binary file. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: - [ExportFlowResponse][google.cloud.dialogflow.cx.v3.ExportFlowResponse] - - Note that resources (e.g. intents, entities, webhooks) that the - flow references will also be exported. - - .. 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 dialogflowcx_v3 - - def sample_export_flow(): - # Create a client - client = dialogflowcx_v3.FlowsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ExportFlowRequest( - name="name_value", - ) - - # Make the request - operation = client.export_flow(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ExportFlowRequest, dict]): - The request object. The request message for - [Flows.ExportFlow][google.cloud.dialogflow.cx.v3.Flows.ExportFlow]. - 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.dialogflowcx_v3.types.ExportFlowResponse` The response message for - [Flows.ExportFlow][google.cloud.dialogflow.cx.v3.Flows.ExportFlow]. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a flow.ExportFlowRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, flow.ExportFlowRequest): - request = flow.ExportFlowRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.export_flow] - - # 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, - flow.ExportFlowResponse, - metadata_type=struct_pb2.Struct, - ) - - # Done; return the response. - return response - - def __enter__(self) -> "FlowsClient": - 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,) - - def get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.get_location, - 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 list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.list_locations, - 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 - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "FlowsClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/pagers.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/pagers.py deleted file mode 100644 index c4d537a7..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/pagers.py +++ /dev/null @@ -1,139 +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.dialogflowcx_v3.types import flow - - -class ListFlowsPager: - """A pager for iterating through ``list_flows`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListFlowsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``flows`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListFlows`` requests and continue to iterate - through the ``flows`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListFlowsResponse` - 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[..., flow.ListFlowsResponse], - request: flow.ListFlowsRequest, - response: flow.ListFlowsResponse, - *, - 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.dialogflowcx_v3.types.ListFlowsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListFlowsResponse): - 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 = flow.ListFlowsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[flow.ListFlowsResponse]: - 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[flow.Flow]: - for page in self.pages: - yield from page.flows - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListFlowsAsyncPager: - """A pager for iterating through ``list_flows`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListFlowsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``flows`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListFlows`` requests and continue to iterate - through the ``flows`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListFlowsResponse` - 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[flow.ListFlowsResponse]], - request: flow.ListFlowsRequest, - response: flow.ListFlowsResponse, - *, - 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.dialogflowcx_v3.types.ListFlowsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListFlowsResponse): - 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 = flow.ListFlowsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[flow.ListFlowsResponse]: - 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[flow.Flow]: - async def async_generator(): - async for page in self.pages: - for response in page.flows: - 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/v3/google/cloud/dialogflowcx_v3/services/flows/transports/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/transports/__init__.py deleted file mode 100644 index 036d7685..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/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 FlowsTransport -from .grpc import FlowsGrpcTransport -from .grpc_asyncio import FlowsGrpcAsyncIOTransport -from .rest import FlowsRestTransport -from .rest import FlowsRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[FlowsTransport]] -_transport_registry['grpc'] = FlowsGrpcTransport -_transport_registry['grpc_asyncio'] = FlowsGrpcAsyncIOTransport -_transport_registry['rest'] = FlowsRestTransport - -__all__ = ( - 'FlowsTransport', - 'FlowsGrpcTransport', - 'FlowsGrpcAsyncIOTransport', - 'FlowsRestTransport', - 'FlowsRestInterceptor', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/transports/base.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/transports/base.py deleted file mode 100644 index 157620da..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/transports/base.py +++ /dev/null @@ -1,329 +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.dialogflowcx_v3 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.dialogflowcx_v3.types import flow -from google.cloud.dialogflowcx_v3.types import flow as gcdc_flow -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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 FlowsTransport(abc.ABC): - """Abstract transport class for Flows.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/dialogflow', - ) - - DEFAULT_HOST: str = 'dialogflow.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_flow: gapic_v1.method.wrap_method( - self.create_flow, - default_timeout=None, - client_info=client_info, - ), - self.delete_flow: gapic_v1.method.wrap_method( - self.delete_flow, - default_timeout=None, - client_info=client_info, - ), - self.list_flows: gapic_v1.method.wrap_method( - self.list_flows, - default_timeout=None, - client_info=client_info, - ), - self.get_flow: gapic_v1.method.wrap_method( - self.get_flow, - default_timeout=None, - client_info=client_info, - ), - self.update_flow: gapic_v1.method.wrap_method( - self.update_flow, - default_timeout=None, - client_info=client_info, - ), - self.train_flow: gapic_v1.method.wrap_method( - self.train_flow, - default_timeout=None, - client_info=client_info, - ), - self.validate_flow: gapic_v1.method.wrap_method( - self.validate_flow, - default_timeout=None, - client_info=client_info, - ), - self.get_flow_validation_result: gapic_v1.method.wrap_method( - self.get_flow_validation_result, - default_timeout=None, - client_info=client_info, - ), - self.import_flow: gapic_v1.method.wrap_method( - self.import_flow, - default_timeout=None, - client_info=client_info, - ), - self.export_flow: gapic_v1.method.wrap_method( - self.export_flow, - 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_flow(self) -> Callable[ - [gcdc_flow.CreateFlowRequest], - Union[ - gcdc_flow.Flow, - Awaitable[gcdc_flow.Flow] - ]]: - raise NotImplementedError() - - @property - def delete_flow(self) -> Callable[ - [flow.DeleteFlowRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def list_flows(self) -> Callable[ - [flow.ListFlowsRequest], - Union[ - flow.ListFlowsResponse, - Awaitable[flow.ListFlowsResponse] - ]]: - raise NotImplementedError() - - @property - def get_flow(self) -> Callable[ - [flow.GetFlowRequest], - Union[ - flow.Flow, - Awaitable[flow.Flow] - ]]: - raise NotImplementedError() - - @property - def update_flow(self) -> Callable[ - [gcdc_flow.UpdateFlowRequest], - Union[ - gcdc_flow.Flow, - Awaitable[gcdc_flow.Flow] - ]]: - raise NotImplementedError() - - @property - def train_flow(self) -> Callable[ - [flow.TrainFlowRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def validate_flow(self) -> Callable[ - [flow.ValidateFlowRequest], - Union[ - flow.FlowValidationResult, - Awaitable[flow.FlowValidationResult] - ]]: - raise NotImplementedError() - - @property - def get_flow_validation_result(self) -> Callable[ - [flow.GetFlowValidationResultRequest], - Union[ - flow.FlowValidationResult, - Awaitable[flow.FlowValidationResult] - ]]: - raise NotImplementedError() - - @property - def import_flow(self) -> Callable[ - [flow.ImportFlowRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def export_flow(self) -> Callable[ - [flow.ExportFlowRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - 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 get_location(self, - ) -> Callable[ - [locations_pb2.GetLocationRequest], - Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], - ]: - raise NotImplementedError() - - @property - def list_locations(self, - ) -> Callable[ - [locations_pb2.ListLocationsRequest], - Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'FlowsTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/transports/grpc.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/transports/grpc.py deleted file mode 100644 index 958436e2..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/transports/grpc.py +++ /dev/null @@ -1,666 +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.dialogflowcx_v3.types import flow -from google.cloud.dialogflowcx_v3.types import flow as gcdc_flow -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import FlowsTransport, DEFAULT_CLIENT_INFO - - -class FlowsGrpcTransport(FlowsTransport): - """gRPC backend transport for Flows. - - Service for managing [Flows][google.cloud.dialogflow.cx.v3.Flow]. - - 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 = 'dialogflow.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 = 'dialogflow.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_flow(self) -> Callable[ - [gcdc_flow.CreateFlowRequest], - gcdc_flow.Flow]: - r"""Return a callable for the create flow method over gRPC. - - Creates a flow in the specified agent. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.CreateFlowRequest], - ~.Flow]: - 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_flow' not in self._stubs: - self._stubs['create_flow'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Flows/CreateFlow', - request_serializer=gcdc_flow.CreateFlowRequest.serialize, - response_deserializer=gcdc_flow.Flow.deserialize, - ) - return self._stubs['create_flow'] - - @property - def delete_flow(self) -> Callable[ - [flow.DeleteFlowRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete flow method over gRPC. - - Deletes a specified flow. - - Returns: - Callable[[~.DeleteFlowRequest], - ~.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_flow' not in self._stubs: - self._stubs['delete_flow'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Flows/DeleteFlow', - request_serializer=flow.DeleteFlowRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_flow'] - - @property - def list_flows(self) -> Callable[ - [flow.ListFlowsRequest], - flow.ListFlowsResponse]: - r"""Return a callable for the list flows method over gRPC. - - Returns the list of all flows in the specified agent. - - Returns: - Callable[[~.ListFlowsRequest], - ~.ListFlowsResponse]: - 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_flows' not in self._stubs: - self._stubs['list_flows'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Flows/ListFlows', - request_serializer=flow.ListFlowsRequest.serialize, - response_deserializer=flow.ListFlowsResponse.deserialize, - ) - return self._stubs['list_flows'] - - @property - def get_flow(self) -> Callable[ - [flow.GetFlowRequest], - flow.Flow]: - r"""Return a callable for the get flow method over gRPC. - - Retrieves the specified flow. - - Returns: - Callable[[~.GetFlowRequest], - ~.Flow]: - 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_flow' not in self._stubs: - self._stubs['get_flow'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Flows/GetFlow', - request_serializer=flow.GetFlowRequest.serialize, - response_deserializer=flow.Flow.deserialize, - ) - return self._stubs['get_flow'] - - @property - def update_flow(self) -> Callable[ - [gcdc_flow.UpdateFlowRequest], - gcdc_flow.Flow]: - r"""Return a callable for the update flow method over gRPC. - - Updates the specified flow. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.UpdateFlowRequest], - ~.Flow]: - 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_flow' not in self._stubs: - self._stubs['update_flow'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Flows/UpdateFlow', - request_serializer=gcdc_flow.UpdateFlowRequest.serialize, - response_deserializer=gcdc_flow.Flow.deserialize, - ) - return self._stubs['update_flow'] - - @property - def train_flow(self) -> Callable[ - [flow.TrainFlowRequest], - operations_pb2.Operation]: - r"""Return a callable for the train flow method over gRPC. - - Trains the specified flow. Note that only the flow in 'draft' - environment is trained. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: An `Empty - message `__ - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.TrainFlowRequest], - ~.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 'train_flow' not in self._stubs: - self._stubs['train_flow'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Flows/TrainFlow', - request_serializer=flow.TrainFlowRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['train_flow'] - - @property - def validate_flow(self) -> Callable[ - [flow.ValidateFlowRequest], - flow.FlowValidationResult]: - r"""Return a callable for the validate flow method over gRPC. - - Validates the specified flow and creates or updates - validation results. Please call this API after the - training is completed to get the complete validation - results. - - Returns: - Callable[[~.ValidateFlowRequest], - ~.FlowValidationResult]: - 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 'validate_flow' not in self._stubs: - self._stubs['validate_flow'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Flows/ValidateFlow', - request_serializer=flow.ValidateFlowRequest.serialize, - response_deserializer=flow.FlowValidationResult.deserialize, - ) - return self._stubs['validate_flow'] - - @property - def get_flow_validation_result(self) -> Callable[ - [flow.GetFlowValidationResultRequest], - flow.FlowValidationResult]: - r"""Return a callable for the get flow validation result method over gRPC. - - Gets the latest flow validation result. Flow - validation is performed when ValidateFlow is called. - - Returns: - Callable[[~.GetFlowValidationResultRequest], - ~.FlowValidationResult]: - 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_flow_validation_result' not in self._stubs: - self._stubs['get_flow_validation_result'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Flows/GetFlowValidationResult', - request_serializer=flow.GetFlowValidationResultRequest.serialize, - response_deserializer=flow.FlowValidationResult.deserialize, - ) - return self._stubs['get_flow_validation_result'] - - @property - def import_flow(self) -> Callable[ - [flow.ImportFlowRequest], - operations_pb2.Operation]: - r"""Return a callable for the import flow method over gRPC. - - Imports the specified flow to the specified agent from a binary - file. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: - [ImportFlowResponse][google.cloud.dialogflow.cx.v3.ImportFlowResponse] - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.ImportFlowRequest], - ~.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 'import_flow' not in self._stubs: - self._stubs['import_flow'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Flows/ImportFlow', - request_serializer=flow.ImportFlowRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['import_flow'] - - @property - def export_flow(self) -> Callable[ - [flow.ExportFlowRequest], - operations_pb2.Operation]: - r"""Return a callable for the export flow method over gRPC. - - Exports the specified flow to a binary file. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: - [ExportFlowResponse][google.cloud.dialogflow.cx.v3.ExportFlowResponse] - - Note that resources (e.g. intents, entities, webhooks) that the - flow references will also be exported. - - Returns: - Callable[[~.ExportFlowRequest], - ~.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_flow' not in self._stubs: - self._stubs['export_flow'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Flows/ExportFlow', - request_serializer=flow.ExportFlowRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['export_flow'] - - 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 list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'FlowsGrpcTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/transports/grpc_asyncio.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/transports/grpc_asyncio.py deleted file mode 100644 index 3aa6b718..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/transports/grpc_asyncio.py +++ /dev/null @@ -1,665 +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.dialogflowcx_v3.types import flow -from google.cloud.dialogflowcx_v3.types import flow as gcdc_flow -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import FlowsTransport, DEFAULT_CLIENT_INFO -from .grpc import FlowsGrpcTransport - - -class FlowsGrpcAsyncIOTransport(FlowsTransport): - """gRPC AsyncIO backend transport for Flows. - - Service for managing [Flows][google.cloud.dialogflow.cx.v3.Flow]. - - 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 = 'dialogflow.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 = 'dialogflow.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_flow(self) -> Callable[ - [gcdc_flow.CreateFlowRequest], - Awaitable[gcdc_flow.Flow]]: - r"""Return a callable for the create flow method over gRPC. - - Creates a flow in the specified agent. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.CreateFlowRequest], - Awaitable[~.Flow]]: - 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_flow' not in self._stubs: - self._stubs['create_flow'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Flows/CreateFlow', - request_serializer=gcdc_flow.CreateFlowRequest.serialize, - response_deserializer=gcdc_flow.Flow.deserialize, - ) - return self._stubs['create_flow'] - - @property - def delete_flow(self) -> Callable[ - [flow.DeleteFlowRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete flow method over gRPC. - - Deletes a specified flow. - - Returns: - Callable[[~.DeleteFlowRequest], - 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_flow' not in self._stubs: - self._stubs['delete_flow'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Flows/DeleteFlow', - request_serializer=flow.DeleteFlowRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_flow'] - - @property - def list_flows(self) -> Callable[ - [flow.ListFlowsRequest], - Awaitable[flow.ListFlowsResponse]]: - r"""Return a callable for the list flows method over gRPC. - - Returns the list of all flows in the specified agent. - - Returns: - Callable[[~.ListFlowsRequest], - Awaitable[~.ListFlowsResponse]]: - 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_flows' not in self._stubs: - self._stubs['list_flows'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Flows/ListFlows', - request_serializer=flow.ListFlowsRequest.serialize, - response_deserializer=flow.ListFlowsResponse.deserialize, - ) - return self._stubs['list_flows'] - - @property - def get_flow(self) -> Callable[ - [flow.GetFlowRequest], - Awaitable[flow.Flow]]: - r"""Return a callable for the get flow method over gRPC. - - Retrieves the specified flow. - - Returns: - Callable[[~.GetFlowRequest], - Awaitable[~.Flow]]: - 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_flow' not in self._stubs: - self._stubs['get_flow'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Flows/GetFlow', - request_serializer=flow.GetFlowRequest.serialize, - response_deserializer=flow.Flow.deserialize, - ) - return self._stubs['get_flow'] - - @property - def update_flow(self) -> Callable[ - [gcdc_flow.UpdateFlowRequest], - Awaitable[gcdc_flow.Flow]]: - r"""Return a callable for the update flow method over gRPC. - - Updates the specified flow. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.UpdateFlowRequest], - Awaitable[~.Flow]]: - 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_flow' not in self._stubs: - self._stubs['update_flow'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Flows/UpdateFlow', - request_serializer=gcdc_flow.UpdateFlowRequest.serialize, - response_deserializer=gcdc_flow.Flow.deserialize, - ) - return self._stubs['update_flow'] - - @property - def train_flow(self) -> Callable[ - [flow.TrainFlowRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the train flow method over gRPC. - - Trains the specified flow. Note that only the flow in 'draft' - environment is trained. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: An `Empty - message `__ - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.TrainFlowRequest], - 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 'train_flow' not in self._stubs: - self._stubs['train_flow'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Flows/TrainFlow', - request_serializer=flow.TrainFlowRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['train_flow'] - - @property - def validate_flow(self) -> Callable[ - [flow.ValidateFlowRequest], - Awaitable[flow.FlowValidationResult]]: - r"""Return a callable for the validate flow method over gRPC. - - Validates the specified flow and creates or updates - validation results. Please call this API after the - training is completed to get the complete validation - results. - - Returns: - Callable[[~.ValidateFlowRequest], - Awaitable[~.FlowValidationResult]]: - 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 'validate_flow' not in self._stubs: - self._stubs['validate_flow'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Flows/ValidateFlow', - request_serializer=flow.ValidateFlowRequest.serialize, - response_deserializer=flow.FlowValidationResult.deserialize, - ) - return self._stubs['validate_flow'] - - @property - def get_flow_validation_result(self) -> Callable[ - [flow.GetFlowValidationResultRequest], - Awaitable[flow.FlowValidationResult]]: - r"""Return a callable for the get flow validation result method over gRPC. - - Gets the latest flow validation result. Flow - validation is performed when ValidateFlow is called. - - Returns: - Callable[[~.GetFlowValidationResultRequest], - Awaitable[~.FlowValidationResult]]: - 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_flow_validation_result' not in self._stubs: - self._stubs['get_flow_validation_result'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Flows/GetFlowValidationResult', - request_serializer=flow.GetFlowValidationResultRequest.serialize, - response_deserializer=flow.FlowValidationResult.deserialize, - ) - return self._stubs['get_flow_validation_result'] - - @property - def import_flow(self) -> Callable[ - [flow.ImportFlowRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the import flow method over gRPC. - - Imports the specified flow to the specified agent from a binary - file. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: - [ImportFlowResponse][google.cloud.dialogflow.cx.v3.ImportFlowResponse] - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.ImportFlowRequest], - 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 'import_flow' not in self._stubs: - self._stubs['import_flow'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Flows/ImportFlow', - request_serializer=flow.ImportFlowRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['import_flow'] - - @property - def export_flow(self) -> Callable[ - [flow.ExportFlowRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the export flow method over gRPC. - - Exports the specified flow to a binary file. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: - [ExportFlowResponse][google.cloud.dialogflow.cx.v3.ExportFlowResponse] - - Note that resources (e.g. intents, entities, webhooks) that the - flow references will also be exported. - - Returns: - Callable[[~.ExportFlowRequest], - 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_flow' not in self._stubs: - self._stubs['export_flow'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Flows/ExportFlow', - request_serializer=flow.ExportFlowRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['export_flow'] - - 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"] - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - -__all__ = ( - 'FlowsGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/transports/rest.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/transports/rest.py deleted file mode 100644 index e57f5f11..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/flows/transports/rest.py +++ /dev/null @@ -1,1891 +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 google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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.dialogflowcx_v3.types import flow -from google.cloud.dialogflowcx_v3.types import flow as gcdc_flow -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore - -from .base import FlowsTransport, 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 FlowsRestInterceptor: - """Interceptor for Flows. - - 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 FlowsRestTransport. - - .. code-block:: python - class MyCustomFlowsInterceptor(FlowsRestInterceptor): - def pre_create_flow(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_flow(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_flow(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_export_flow(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_export_flow(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_flow(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_flow(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_flow_validation_result(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_flow_validation_result(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_import_flow(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_import_flow(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_flows(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_flows(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_train_flow(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_train_flow(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_flow(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_flow(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_validate_flow(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_validate_flow(self, response): - logging.log(f"Received response: {response}") - return response - - transport = FlowsRestTransport(interceptor=MyCustomFlowsInterceptor()) - client = FlowsClient(transport=transport) - - - """ - def pre_create_flow(self, request: gcdc_flow.CreateFlowRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_flow.CreateFlowRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_flow - - Override in a subclass to manipulate the request or metadata - before they are sent to the Flows server. - """ - return request, metadata - - def post_create_flow(self, response: gcdc_flow.Flow) -> gcdc_flow.Flow: - """Post-rpc interceptor for create_flow - - Override in a subclass to manipulate the response - after it is returned by the Flows server but before - it is returned to user code. - """ - return response - def pre_delete_flow(self, request: flow.DeleteFlowRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[flow.DeleteFlowRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_flow - - Override in a subclass to manipulate the request or metadata - before they are sent to the Flows server. - """ - return request, metadata - - def pre_export_flow(self, request: flow.ExportFlowRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[flow.ExportFlowRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for export_flow - - Override in a subclass to manipulate the request or metadata - before they are sent to the Flows server. - """ - return request, metadata - - def post_export_flow(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for export_flow - - Override in a subclass to manipulate the response - after it is returned by the Flows server but before - it is returned to user code. - """ - return response - def pre_get_flow(self, request: flow.GetFlowRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[flow.GetFlowRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_flow - - Override in a subclass to manipulate the request or metadata - before they are sent to the Flows server. - """ - return request, metadata - - def post_get_flow(self, response: flow.Flow) -> flow.Flow: - """Post-rpc interceptor for get_flow - - Override in a subclass to manipulate the response - after it is returned by the Flows server but before - it is returned to user code. - """ - return response - def pre_get_flow_validation_result(self, request: flow.GetFlowValidationResultRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[flow.GetFlowValidationResultRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_flow_validation_result - - Override in a subclass to manipulate the request or metadata - before they are sent to the Flows server. - """ - return request, metadata - - def post_get_flow_validation_result(self, response: flow.FlowValidationResult) -> flow.FlowValidationResult: - """Post-rpc interceptor for get_flow_validation_result - - Override in a subclass to manipulate the response - after it is returned by the Flows server but before - it is returned to user code. - """ - return response - def pre_import_flow(self, request: flow.ImportFlowRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[flow.ImportFlowRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for import_flow - - Override in a subclass to manipulate the request or metadata - before they are sent to the Flows server. - """ - return request, metadata - - def post_import_flow(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for import_flow - - Override in a subclass to manipulate the response - after it is returned by the Flows server but before - it is returned to user code. - """ - return response - def pre_list_flows(self, request: flow.ListFlowsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[flow.ListFlowsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_flows - - Override in a subclass to manipulate the request or metadata - before they are sent to the Flows server. - """ - return request, metadata - - def post_list_flows(self, response: flow.ListFlowsResponse) -> flow.ListFlowsResponse: - """Post-rpc interceptor for list_flows - - Override in a subclass to manipulate the response - after it is returned by the Flows server but before - it is returned to user code. - """ - return response - def pre_train_flow(self, request: flow.TrainFlowRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[flow.TrainFlowRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for train_flow - - Override in a subclass to manipulate the request or metadata - before they are sent to the Flows server. - """ - return request, metadata - - def post_train_flow(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for train_flow - - Override in a subclass to manipulate the response - after it is returned by the Flows server but before - it is returned to user code. - """ - return response - def pre_update_flow(self, request: gcdc_flow.UpdateFlowRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_flow.UpdateFlowRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_flow - - Override in a subclass to manipulate the request or metadata - before they are sent to the Flows server. - """ - return request, metadata - - def post_update_flow(self, response: gcdc_flow.Flow) -> gcdc_flow.Flow: - """Post-rpc interceptor for update_flow - - Override in a subclass to manipulate the response - after it is returned by the Flows server but before - it is returned to user code. - """ - return response - def pre_validate_flow(self, request: flow.ValidateFlowRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[flow.ValidateFlowRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for validate_flow - - Override in a subclass to manipulate the request or metadata - before they are sent to the Flows server. - """ - return request, metadata - - def post_validate_flow(self, response: flow.FlowValidationResult) -> flow.FlowValidationResult: - """Post-rpc interceptor for validate_flow - - Override in a subclass to manipulate the response - after it is returned by the Flows server but before - it is returned to user code. - """ - return response - - def pre_get_location( - self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_location - - Override in a subclass to manipulate the request or metadata - before they are sent to the Flows server. - """ - return request, metadata - - def post_get_location( - self, response: locations_pb2.Location - ) -> locations_pb2.Location: - """Post-rpc interceptor for get_location - - Override in a subclass to manipulate the response - after it is returned by the Flows server but before - it is returned to user code. - """ - return response - def pre_list_locations( - self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_locations - - Override in a subclass to manipulate the request or metadata - before they are sent to the Flows server. - """ - return request, metadata - - def post_list_locations( - self, response: locations_pb2.ListLocationsResponse - ) -> locations_pb2.ListLocationsResponse: - """Post-rpc interceptor for list_locations - - Override in a subclass to manipulate the response - after it is returned by the Flows 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 Flows 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 Flows 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 Flows 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 Flows 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 Flows 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 Flows server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class FlowsRestStub: - _session: AuthorizedSession - _host: str - _interceptor: FlowsRestInterceptor - - -class FlowsRestTransport(FlowsTransport): - """REST backend transport for Flows. - - Service for managing [Flows][google.cloud.dialogflow.cx.v3.Flow]. - - 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 = 'dialogflow.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[FlowsRestInterceptor] = 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 FlowsRestInterceptor() - 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': '/v3/{name=projects/*/operations/*}:cancel', - }, - { - 'method': 'post', - 'uri': '/v3/{name=projects/*/locations/*/operations/*}:cancel', - }, - ], - 'google.longrunning.Operations.GetOperation': [ - { - 'method': 'get', - 'uri': '/v3/{name=projects/*/operations/*}', - }, - { - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/operations/*}', - }, - ], - 'google.longrunning.Operations.ListOperations': [ - { - 'method': 'get', - 'uri': '/v3/{name=projects/*}/operations', - }, - { - 'method': 'get', - 'uri': '/v3/{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="v3") - - self._operations_client = operations_v1.AbstractOperationsClient(transport=rest_transport) - - # Return the client from cache. - return self._operations_client - - class _CreateFlow(FlowsRestStub): - def __hash__(self): - return hash("CreateFlow") - - __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: gcdc_flow.CreateFlowRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_flow.Flow: - r"""Call the create flow method over HTTP. - - Args: - request (~.gcdc_flow.CreateFlowRequest): - The request object. The request message for - [Flows.CreateFlow][google.cloud.dialogflow.cx.v3.Flows.CreateFlow]. - 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: - ~.gcdc_flow.Flow: - Flows represents the conversation - flows when you build your chatbot agent. - A flow consists of many pages connected - by the transition routes. Conversations - always start with the built-in Start - Flow (with an all-0 ID). Transition - routes can direct the conversation - session from the current flow (parent - flow) to another flow (sub flow). When - the sub flow is finished, Dialogflow - will bring the session back to the - parent flow, where the sub flow is - started. - - Usually, when a transition route is - followed by a matched intent, the intent - will be "consumed". This means the - intent won't activate more transition - routes. However, when the followed - transition route moves the conversation - session into a different flow, the - matched intent can be carried over and - to be consumed in the target flow. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*}/flows', - 'body': 'flow', - }, - ] - request, metadata = self._interceptor.pre_create_flow(request, metadata) - pb_request = gcdc_flow.CreateFlowRequest.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 = gcdc_flow.Flow() - pb_resp = gcdc_flow.Flow.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_flow(resp) - return resp - - class _DeleteFlow(FlowsRestStub): - def __hash__(self): - return hash("DeleteFlow") - - __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: flow.DeleteFlowRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete flow method over HTTP. - - Args: - request (~.flow.DeleteFlowRequest): - The request object. The request message for - [Flows.DeleteFlow][google.cloud.dialogflow.cx.v3.Flows.DeleteFlow]. - 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': '/v3/{name=projects/*/locations/*/agents/*/flows/*}', - }, - ] - request, metadata = self._interceptor.pre_delete_flow(request, metadata) - pb_request = flow.DeleteFlowRequest.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 _ExportFlow(FlowsRestStub): - def __hash__(self): - return hash("ExportFlow") - - __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: flow.ExportFlowRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the export flow method over HTTP. - - Args: - request (~.flow.ExportFlowRequest): - The request object. The request message for - [Flows.ExportFlow][google.cloud.dialogflow.cx.v3.Flows.ExportFlow]. - 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': '/v3/{name=projects/*/locations/*/agents/*/flows/*}:export', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_export_flow(request, metadata) - pb_request = flow.ExportFlowRequest.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_flow(resp) - return resp - - class _GetFlow(FlowsRestStub): - def __hash__(self): - return hash("GetFlow") - - __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: flow.GetFlowRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> flow.Flow: - r"""Call the get flow method over HTTP. - - Args: - request (~.flow.GetFlowRequest): - The request object. The response message for - [Flows.GetFlow][google.cloud.dialogflow.cx.v3.Flows.GetFlow]. - 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: - ~.flow.Flow: - Flows represents the conversation - flows when you build your chatbot agent. - A flow consists of many pages connected - by the transition routes. Conversations - always start with the built-in Start - Flow (with an all-0 ID). Transition - routes can direct the conversation - session from the current flow (parent - flow) to another flow (sub flow). When - the sub flow is finished, Dialogflow - will bring the session back to the - parent flow, where the sub flow is - started. - - Usually, when a transition route is - followed by a matched intent, the intent - will be "consumed". This means the - intent won't activate more transition - routes. However, when the followed - transition route moves the conversation - session into a different flow, the - matched intent can be carried over and - to be consumed in the target flow. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/flows/*}', - }, - ] - request, metadata = self._interceptor.pre_get_flow(request, metadata) - pb_request = flow.GetFlowRequest.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 = flow.Flow() - pb_resp = flow.Flow.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_flow(resp) - return resp - - class _GetFlowValidationResult(FlowsRestStub): - def __hash__(self): - return hash("GetFlowValidationResult") - - __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: flow.GetFlowValidationResultRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> flow.FlowValidationResult: - r"""Call the get flow validation - result method over HTTP. - - Args: - request (~.flow.GetFlowValidationResultRequest): - The request object. The request message for - [Flows.GetFlowValidationResult][google.cloud.dialogflow.cx.v3.Flows.GetFlowValidationResult]. - 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: - ~.flow.FlowValidationResult: - The response message for - [Flows.GetFlowValidationResult][google.cloud.dialogflow.cx.v3.Flows.GetFlowValidationResult]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/flows/*/validationResult}', - }, - ] - request, metadata = self._interceptor.pre_get_flow_validation_result(request, metadata) - pb_request = flow.GetFlowValidationResultRequest.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 = flow.FlowValidationResult() - pb_resp = flow.FlowValidationResult.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_flow_validation_result(resp) - return resp - - class _ImportFlow(FlowsRestStub): - def __hash__(self): - return hash("ImportFlow") - - __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: flow.ImportFlowRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the import flow method over HTTP. - - Args: - request (~.flow.ImportFlowRequest): - The request object. The request message for - [Flows.ImportFlow][google.cloud.dialogflow.cx.v3.Flows.ImportFlow]. - 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': '/v3/{parent=projects/*/locations/*/agents/*}/flows:import', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_import_flow(request, metadata) - pb_request = flow.ImportFlowRequest.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_import_flow(resp) - return resp - - class _ListFlows(FlowsRestStub): - def __hash__(self): - return hash("ListFlows") - - __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: flow.ListFlowsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> flow.ListFlowsResponse: - r"""Call the list flows method over HTTP. - - Args: - request (~.flow.ListFlowsRequest): - The request object. The request message for - [Flows.ListFlows][google.cloud.dialogflow.cx.v3.Flows.ListFlows]. - 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: - ~.flow.ListFlowsResponse: - The response message for - [Flows.ListFlows][google.cloud.dialogflow.cx.v3.Flows.ListFlows]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*}/flows', - }, - ] - request, metadata = self._interceptor.pre_list_flows(request, metadata) - pb_request = flow.ListFlowsRequest.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 = flow.ListFlowsResponse() - pb_resp = flow.ListFlowsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_flows(resp) - return resp - - class _TrainFlow(FlowsRestStub): - def __hash__(self): - return hash("TrainFlow") - - __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: flow.TrainFlowRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the train flow method over HTTP. - - Args: - request (~.flow.TrainFlowRequest): - The request object. The request message for - [Flows.TrainFlow][google.cloud.dialogflow.cx.v3.Flows.TrainFlow]. - 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': '/v3/{name=projects/*/locations/*/agents/*/flows/*}:train', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_train_flow(request, metadata) - pb_request = flow.TrainFlowRequest.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_train_flow(resp) - return resp - - class _UpdateFlow(FlowsRestStub): - def __hash__(self): - return hash("UpdateFlow") - - __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: gcdc_flow.UpdateFlowRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_flow.Flow: - r"""Call the update flow method over HTTP. - - Args: - request (~.gcdc_flow.UpdateFlowRequest): - The request object. The request message for - [Flows.UpdateFlow][google.cloud.dialogflow.cx.v3.Flows.UpdateFlow]. - 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: - ~.gcdc_flow.Flow: - Flows represents the conversation - flows when you build your chatbot agent. - A flow consists of many pages connected - by the transition routes. Conversations - always start with the built-in Start - Flow (with an all-0 ID). Transition - routes can direct the conversation - session from the current flow (parent - flow) to another flow (sub flow). When - the sub flow is finished, Dialogflow - will bring the session back to the - parent flow, where the sub flow is - started. - - Usually, when a transition route is - followed by a matched intent, the intent - will be "consumed". This means the - intent won't activate more transition - routes. However, when the followed - transition route moves the conversation - session into a different flow, the - matched intent can be carried over and - to be consumed in the target flow. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v3/{flow.name=projects/*/locations/*/agents/*/flows/*}', - 'body': 'flow', - }, - ] - request, metadata = self._interceptor.pre_update_flow(request, metadata) - pb_request = gcdc_flow.UpdateFlowRequest.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 = gcdc_flow.Flow() - pb_resp = gcdc_flow.Flow.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_flow(resp) - return resp - - class _ValidateFlow(FlowsRestStub): - def __hash__(self): - return hash("ValidateFlow") - - __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: flow.ValidateFlowRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> flow.FlowValidationResult: - r"""Call the validate flow method over HTTP. - - Args: - request (~.flow.ValidateFlowRequest): - The request object. The request message for - [Flows.ValidateFlow][google.cloud.dialogflow.cx.v3.Flows.ValidateFlow]. - 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: - ~.flow.FlowValidationResult: - The response message for - [Flows.GetFlowValidationResult][google.cloud.dialogflow.cx.v3.Flows.GetFlowValidationResult]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/flows/*}:validate', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_validate_flow(request, metadata) - pb_request = flow.ValidateFlowRequest.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 = flow.FlowValidationResult() - pb_resp = flow.FlowValidationResult.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_validate_flow(resp) - return resp - - @property - def create_flow(self) -> Callable[ - [gcdc_flow.CreateFlowRequest], - gcdc_flow.Flow]: - # 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._CreateFlow(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_flow(self) -> Callable[ - [flow.DeleteFlowRequest], - 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._DeleteFlow(self._session, self._host, self._interceptor) # type: ignore - - @property - def export_flow(self) -> Callable[ - [flow.ExportFlowRequest], - 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._ExportFlow(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_flow(self) -> Callable[ - [flow.GetFlowRequest], - flow.Flow]: - # 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._GetFlow(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_flow_validation_result(self) -> Callable[ - [flow.GetFlowValidationResultRequest], - flow.FlowValidationResult]: - # 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._GetFlowValidationResult(self._session, self._host, self._interceptor) # type: ignore - - @property - def import_flow(self) -> Callable[ - [flow.ImportFlowRequest], - 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._ImportFlow(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_flows(self) -> Callable[ - [flow.ListFlowsRequest], - flow.ListFlowsResponse]: - # 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._ListFlows(self._session, self._host, self._interceptor) # type: ignore - - @property - def train_flow(self) -> Callable[ - [flow.TrainFlowRequest], - 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._TrainFlow(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_flow(self) -> Callable[ - [gcdc_flow.UpdateFlowRequest], - gcdc_flow.Flow]: - # 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._UpdateFlow(self._session, self._host, self._interceptor) # type: ignore - - @property - def validate_flow(self) -> Callable[ - [flow.ValidateFlowRequest], - flow.FlowValidationResult]: - # 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._ValidateFlow(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_location(self): - return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore - - class _GetLocation(FlowsRestStub): - def __call__(self, - request: locations_pb2.GetLocationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.Location: - - r"""Call the get location method over HTTP. - - Args: - request (locations_pb2.GetLocationRequest): - The request object for GetLocation 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: - locations_pb2.Location: Response from GetLocation method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*}', - }, - ] - - request, metadata = self._interceptor.pre_get_location(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 = locations_pb2.Location() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_get_location(resp) - return resp - - @property - def list_locations(self): - return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore - - class _ListLocations(FlowsRestStub): - def __call__(self, - request: locations_pb2.ListLocationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.ListLocationsResponse: - - r"""Call the list locations method over HTTP. - - Args: - request (locations_pb2.ListLocationsRequest): - The request object for ListLocations 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: - locations_pb2.ListLocationsResponse: Response from ListLocations method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*}/locations', - }, - ] - - request, metadata = self._interceptor.pre_list_locations(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 = locations_pb2.ListLocationsResponse() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_list_locations(resp) - return resp - - @property - def cancel_operation(self): - return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore - - class _CancelOperation(FlowsRestStub): - 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': '/v3/{name=projects/*/operations/*}:cancel', - }, -{ - 'method': 'post', - 'uri': '/v3/{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(FlowsRestStub): - 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': '/v3/{name=projects/*/operations/*}', - }, -{ - 'method': 'get', - 'uri': '/v3/{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(FlowsRestStub): - 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': '/v3/{name=projects/*}/operations', - }, -{ - 'method': 'get', - 'uri': '/v3/{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__=( - 'FlowsRestTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/__init__.py deleted file mode 100644 index 4b2b51aa..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/__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 IntentsClient -from .async_client import IntentsAsyncClient - -__all__ = ( - 'IntentsClient', - 'IntentsAsyncClient', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/async_client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/async_client.py deleted file mode 100644 index 5642abff..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/async_client.py +++ /dev/null @@ -1,1018 +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.dialogflowcx_v3 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.cloud.dialogflowcx_v3.services.intents import pagers -from google.cloud.dialogflowcx_v3.types import intent -from google.cloud.dialogflowcx_v3.types import intent as gcdc_intent -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import IntentsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import IntentsGrpcAsyncIOTransport -from .client import IntentsClient - - -class IntentsAsyncClient: - """Service for managing - [Intents][google.cloud.dialogflow.cx.v3.Intent]. - """ - - _client: IntentsClient - - DEFAULT_ENDPOINT = IntentsClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = IntentsClient.DEFAULT_MTLS_ENDPOINT - - entity_type_path = staticmethod(IntentsClient.entity_type_path) - parse_entity_type_path = staticmethod(IntentsClient.parse_entity_type_path) - intent_path = staticmethod(IntentsClient.intent_path) - parse_intent_path = staticmethod(IntentsClient.parse_intent_path) - common_billing_account_path = staticmethod(IntentsClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(IntentsClient.parse_common_billing_account_path) - common_folder_path = staticmethod(IntentsClient.common_folder_path) - parse_common_folder_path = staticmethod(IntentsClient.parse_common_folder_path) - common_organization_path = staticmethod(IntentsClient.common_organization_path) - parse_common_organization_path = staticmethod(IntentsClient.parse_common_organization_path) - common_project_path = staticmethod(IntentsClient.common_project_path) - parse_common_project_path = staticmethod(IntentsClient.parse_common_project_path) - common_location_path = staticmethod(IntentsClient.common_location_path) - parse_common_location_path = staticmethod(IntentsClient.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: - IntentsAsyncClient: The constructed client. - """ - return IntentsClient.from_service_account_info.__func__(IntentsAsyncClient, 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: - IntentsAsyncClient: The constructed client. - """ - return IntentsClient.from_service_account_file.__func__(IntentsAsyncClient, 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 IntentsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> IntentsTransport: - """Returns the transport used by the client instance. - - Returns: - IntentsTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(IntentsClient).get_transport_class, type(IntentsClient)) - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, IntentsTransport] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the intents 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, ~.IntentsTransport]): 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 = IntentsClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def list_intents(self, - request: Optional[Union[intent.ListIntentsRequest, 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.ListIntentsAsyncPager: - r"""Returns the list of all intents in the specified - agent. - - .. 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 dialogflowcx_v3 - - async def sample_list_intents(): - # Create a client - client = dialogflowcx_v3.IntentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListIntentsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_intents(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ListIntentsRequest, dict]]): - The request object. The request message for - [Intents.ListIntents][google.cloud.dialogflow.cx.v3.Intents.ListIntents]. - parent (:class:`str`): - Required. The agent to list all intents for. Format: - ``projects//locations//agents/``. - - 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.dialogflowcx_v3.services.intents.pagers.ListIntentsAsyncPager: - The response message for - [Intents.ListIntents][google.cloud.dialogflow.cx.v3.Intents.ListIntents]. - - 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 = intent.ListIntentsRequest(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_intents, - 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.ListIntentsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_intent(self, - request: Optional[Union[intent.GetIntentRequest, 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]] = (), - ) -> intent.Intent: - r"""Retrieves the specified intent. - - .. 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 dialogflowcx_v3 - - async def sample_get_intent(): - # Create a client - client = dialogflowcx_v3.IntentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetIntentRequest( - name="name_value", - ) - - # Make the request - response = await client.get_intent(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.GetIntentRequest, dict]]): - The request object. The request message for - [Intents.GetIntent][google.cloud.dialogflow.cx.v3.Intents.GetIntent]. - name (:class:`str`): - Required. The name of the intent. Format: - ``projects//locations//agents//intents/``. - - 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.dialogflowcx_v3.types.Intent: - An intent represents a user's intent - to interact with a conversational agent. - You can provide information for the - Dialogflow API to use to match user - input to an intent by adding training - phrases (i.e., examples of user input) - to your intent. - - """ - # 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 = intent.GetIntentRequest(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_intent, - 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 create_intent(self, - request: Optional[Union[gcdc_intent.CreateIntentRequest, dict]] = None, - *, - parent: Optional[str] = None, - intent: Optional[gcdc_intent.Intent] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_intent.Intent: - r"""Creates an intent in the specified agent. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - async def sample_create_intent(): - # Create a client - client = dialogflowcx_v3.IntentsAsyncClient() - - # Initialize request argument(s) - intent = dialogflowcx_v3.Intent() - intent.display_name = "display_name_value" - - request = dialogflowcx_v3.CreateIntentRequest( - parent="parent_value", - intent=intent, - ) - - # Make the request - response = await client.create_intent(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.CreateIntentRequest, dict]]): - The request object. The request message for - [Intents.CreateIntent][google.cloud.dialogflow.cx.v3.Intents.CreateIntent]. - parent (:class:`str`): - Required. The agent to create an intent for. Format: - ``projects//locations//agents/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - intent (:class:`google.cloud.dialogflowcx_v3.types.Intent`): - Required. The intent to create. - This corresponds to the ``intent`` 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.dialogflowcx_v3.types.Intent: - An intent represents a user's intent - to interact with a conversational agent. - You can provide information for the - Dialogflow API to use to match user - input to an intent by adding training - phrases (i.e., examples of user input) - to your intent. - - """ - # 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, intent]) - 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 = gcdc_intent.CreateIntentRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if intent is not None: - request.intent = intent - - # 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_intent, - 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_intent(self, - request: Optional[Union[gcdc_intent.UpdateIntentRequest, dict]] = None, - *, - intent: Optional[gcdc_intent.Intent] = 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]] = (), - ) -> gcdc_intent.Intent: - r"""Updates the specified intent. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - async def sample_update_intent(): - # Create a client - client = dialogflowcx_v3.IntentsAsyncClient() - - # Initialize request argument(s) - intent = dialogflowcx_v3.Intent() - intent.display_name = "display_name_value" - - request = dialogflowcx_v3.UpdateIntentRequest( - intent=intent, - ) - - # Make the request - response = await client.update_intent(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.UpdateIntentRequest, dict]]): - The request object. The request message for - [Intents.UpdateIntent][google.cloud.dialogflow.cx.v3.Intents.UpdateIntent]. - intent (:class:`google.cloud.dialogflowcx_v3.types.Intent`): - Required. The intent to update. - This corresponds to the ``intent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The mask to control which fields get - updated. If the mask is not present, all - fields will 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.dialogflowcx_v3.types.Intent: - An intent represents a user's intent - to interact with a conversational agent. - You can provide information for the - Dialogflow API to use to match user - input to an intent by adding training - phrases (i.e., examples of user input) - to your intent. - - """ - # 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([intent, 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 = gcdc_intent.UpdateIntentRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if intent is not None: - request.intent = intent - 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_intent, - 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(( - ("intent.name", request.intent.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_intent(self, - request: Optional[Union[intent.DeleteIntentRequest, 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 the specified intent. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - async def sample_delete_intent(): - # Create a client - client = dialogflowcx_v3.IntentsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteIntentRequest( - name="name_value", - ) - - # Make the request - await client.delete_intent(request=request) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.DeleteIntentRequest, dict]]): - The request object. The request message for - [Intents.DeleteIntent][google.cloud.dialogflow.cx.v3.Intents.DeleteIntent]. - name (:class:`str`): - Required. The name of the intent to delete. Format: - ``projects//locations//agents//intents/``. - - 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 = intent.DeleteIntentRequest(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_intent, - 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 get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**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_location, - 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_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**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_locations, - 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 __aenter__(self) -> "IntentsAsyncClient": - 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__ = ( - "IntentsAsyncClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/client.py deleted file mode 100644 index 8e870381..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/client.py +++ /dev/null @@ -1,1226 +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.dialogflowcx_v3 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.cloud.dialogflowcx_v3.services.intents import pagers -from google.cloud.dialogflowcx_v3.types import intent -from google.cloud.dialogflowcx_v3.types import intent as gcdc_intent -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import IntentsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import IntentsGrpcTransport -from .transports.grpc_asyncio import IntentsGrpcAsyncIOTransport -from .transports.rest import IntentsRestTransport - - -class IntentsClientMeta(type): - """Metaclass for the Intents 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[IntentsTransport]] - _transport_registry["grpc"] = IntentsGrpcTransport - _transport_registry["grpc_asyncio"] = IntentsGrpcAsyncIOTransport - _transport_registry["rest"] = IntentsRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[IntentsTransport]: - """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 IntentsClient(metaclass=IntentsClientMeta): - """Service for managing - [Intents][google.cloud.dialogflow.cx.v3.Intent]. - """ - - @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 = "dialogflow.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: - IntentsClient: 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: - IntentsClient: 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) -> IntentsTransport: - """Returns the transport used by the client instance. - - Returns: - IntentsTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def entity_type_path(project: str,location: str,agent: str,entity_type: str,) -> str: - """Returns a fully-qualified entity_type string.""" - return "projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type}".format(project=project, location=location, agent=agent, entity_type=entity_type, ) - - @staticmethod - def parse_entity_type_path(path: str) -> Dict[str,str]: - """Parses a entity_type path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/entityTypes/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def intent_path(project: str,location: str,agent: str,intent: str,) -> str: - """Returns a fully-qualified intent string.""" - return "projects/{project}/locations/{location}/agents/{agent}/intents/{intent}".format(project=project, location=location, agent=agent, intent=intent, ) - - @staticmethod - def parse_intent_path(path: str) -> Dict[str,str]: - """Parses a intent path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/intents/(?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, IntentsTransport]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the intents 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, IntentsTransport]): 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, IntentsTransport): - # transport is a IntentsTransport 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 list_intents(self, - request: Optional[Union[intent.ListIntentsRequest, 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.ListIntentsPager: - r"""Returns the list of all intents in the specified - agent. - - .. 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 dialogflowcx_v3 - - def sample_list_intents(): - # Create a client - client = dialogflowcx_v3.IntentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListIntentsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_intents(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ListIntentsRequest, dict]): - The request object. The request message for - [Intents.ListIntents][google.cloud.dialogflow.cx.v3.Intents.ListIntents]. - parent (str): - Required. The agent to list all intents for. Format: - ``projects//locations//agents/``. - - 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.dialogflowcx_v3.services.intents.pagers.ListIntentsPager: - The response message for - [Intents.ListIntents][google.cloud.dialogflow.cx.v3.Intents.ListIntents]. - - 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 intent.ListIntentsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, intent.ListIntentsRequest): - request = intent.ListIntentsRequest(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_intents] - - # 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.ListIntentsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_intent(self, - request: Optional[Union[intent.GetIntentRequest, 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]] = (), - ) -> intent.Intent: - r"""Retrieves the specified intent. - - .. 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 dialogflowcx_v3 - - def sample_get_intent(): - # Create a client - client = dialogflowcx_v3.IntentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetIntentRequest( - name="name_value", - ) - - # Make the request - response = client.get_intent(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.GetIntentRequest, dict]): - The request object. The request message for - [Intents.GetIntent][google.cloud.dialogflow.cx.v3.Intents.GetIntent]. - name (str): - Required. The name of the intent. Format: - ``projects//locations//agents//intents/``. - - 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.dialogflowcx_v3.types.Intent: - An intent represents a user's intent - to interact with a conversational agent. - You can provide information for the - Dialogflow API to use to match user - input to an intent by adding training - phrases (i.e., examples of user input) - to your intent. - - """ - # 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 intent.GetIntentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, intent.GetIntentRequest): - request = intent.GetIntentRequest(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_intent] - - # 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 create_intent(self, - request: Optional[Union[gcdc_intent.CreateIntentRequest, dict]] = None, - *, - parent: Optional[str] = None, - intent: Optional[gcdc_intent.Intent] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_intent.Intent: - r"""Creates an intent in the specified agent. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - def sample_create_intent(): - # Create a client - client = dialogflowcx_v3.IntentsClient() - - # Initialize request argument(s) - intent = dialogflowcx_v3.Intent() - intent.display_name = "display_name_value" - - request = dialogflowcx_v3.CreateIntentRequest( - parent="parent_value", - intent=intent, - ) - - # Make the request - response = client.create_intent(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.CreateIntentRequest, dict]): - The request object. The request message for - [Intents.CreateIntent][google.cloud.dialogflow.cx.v3.Intents.CreateIntent]. - parent (str): - Required. The agent to create an intent for. Format: - ``projects//locations//agents/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - intent (google.cloud.dialogflowcx_v3.types.Intent): - Required. The intent to create. - This corresponds to the ``intent`` 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.dialogflowcx_v3.types.Intent: - An intent represents a user's intent - to interact with a conversational agent. - You can provide information for the - Dialogflow API to use to match user - input to an intent by adding training - phrases (i.e., examples of user input) - to your intent. - - """ - # 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, intent]) - 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 gcdc_intent.CreateIntentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_intent.CreateIntentRequest): - request = gcdc_intent.CreateIntentRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if intent is not None: - request.intent = intent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_intent] - - # 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_intent(self, - request: Optional[Union[gcdc_intent.UpdateIntentRequest, dict]] = None, - *, - intent: Optional[gcdc_intent.Intent] = 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]] = (), - ) -> gcdc_intent.Intent: - r"""Updates the specified intent. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - def sample_update_intent(): - # Create a client - client = dialogflowcx_v3.IntentsClient() - - # Initialize request argument(s) - intent = dialogflowcx_v3.Intent() - intent.display_name = "display_name_value" - - request = dialogflowcx_v3.UpdateIntentRequest( - intent=intent, - ) - - # Make the request - response = client.update_intent(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.UpdateIntentRequest, dict]): - The request object. The request message for - [Intents.UpdateIntent][google.cloud.dialogflow.cx.v3.Intents.UpdateIntent]. - intent (google.cloud.dialogflowcx_v3.types.Intent): - Required. The intent to update. - This corresponds to the ``intent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The mask to control which fields get - updated. If the mask is not present, all - fields will 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.dialogflowcx_v3.types.Intent: - An intent represents a user's intent - to interact with a conversational agent. - You can provide information for the - Dialogflow API to use to match user - input to an intent by adding training - phrases (i.e., examples of user input) - to your intent. - - """ - # 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([intent, 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 gcdc_intent.UpdateIntentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_intent.UpdateIntentRequest): - request = gcdc_intent.UpdateIntentRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if intent is not None: - request.intent = intent - 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_intent] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("intent.name", request.intent.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_intent(self, - request: Optional[Union[intent.DeleteIntentRequest, 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 the specified intent. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - def sample_delete_intent(): - # Create a client - client = dialogflowcx_v3.IntentsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteIntentRequest( - name="name_value", - ) - - # Make the request - client.delete_intent(request=request) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.DeleteIntentRequest, dict]): - The request object. The request message for - [Intents.DeleteIntent][google.cloud.dialogflow.cx.v3.Intents.DeleteIntent]. - name (str): - Required. The name of the intent to delete. Format: - ``projects//locations//agents//intents/``. - - 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 intent.DeleteIntentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, intent.DeleteIntentRequest): - request = intent.DeleteIntentRequest(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_intent] - - # 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) -> "IntentsClient": - 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,) - - def get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.get_location, - 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 list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.list_locations, - 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 - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "IntentsClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/pagers.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/pagers.py deleted file mode 100644 index 5ae804b1..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/pagers.py +++ /dev/null @@ -1,139 +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.dialogflowcx_v3.types import intent - - -class ListIntentsPager: - """A pager for iterating through ``list_intents`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListIntentsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``intents`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListIntents`` requests and continue to iterate - through the ``intents`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListIntentsResponse` - 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[..., intent.ListIntentsResponse], - request: intent.ListIntentsRequest, - response: intent.ListIntentsResponse, - *, - 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.dialogflowcx_v3.types.ListIntentsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListIntentsResponse): - 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 = intent.ListIntentsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[intent.ListIntentsResponse]: - 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[intent.Intent]: - for page in self.pages: - yield from page.intents - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListIntentsAsyncPager: - """A pager for iterating through ``list_intents`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListIntentsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``intents`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListIntents`` requests and continue to iterate - through the ``intents`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListIntentsResponse` - 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[intent.ListIntentsResponse]], - request: intent.ListIntentsRequest, - response: intent.ListIntentsResponse, - *, - 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.dialogflowcx_v3.types.ListIntentsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListIntentsResponse): - 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 = intent.ListIntentsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[intent.ListIntentsResponse]: - 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[intent.Intent]: - async def async_generator(): - async for page in self.pages: - for response in page.intents: - 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/v3/google/cloud/dialogflowcx_v3/services/intents/transports/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/transports/__init__.py deleted file mode 100644 index bae51ab7..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/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 IntentsTransport -from .grpc import IntentsGrpcTransport -from .grpc_asyncio import IntentsGrpcAsyncIOTransport -from .rest import IntentsRestTransport -from .rest import IntentsRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[IntentsTransport]] -_transport_registry['grpc'] = IntentsGrpcTransport -_transport_registry['grpc_asyncio'] = IntentsGrpcAsyncIOTransport -_transport_registry['rest'] = IntentsRestTransport - -__all__ = ( - 'IntentsTransport', - 'IntentsGrpcTransport', - 'IntentsGrpcAsyncIOTransport', - 'IntentsRestTransport', - 'IntentsRestInterceptor', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/transports/base.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/transports/base.py deleted file mode 100644 index 92eff14e..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/transports/base.py +++ /dev/null @@ -1,252 +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.dialogflowcx_v3 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.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.dialogflowcx_v3.types import intent -from google.cloud.dialogflowcx_v3.types import intent as gcdc_intent -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -class IntentsTransport(abc.ABC): - """Abstract transport class for Intents.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/dialogflow', - ) - - DEFAULT_HOST: str = 'dialogflow.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.list_intents: gapic_v1.method.wrap_method( - self.list_intents, - default_timeout=None, - client_info=client_info, - ), - self.get_intent: gapic_v1.method.wrap_method( - self.get_intent, - default_timeout=None, - client_info=client_info, - ), - self.create_intent: gapic_v1.method.wrap_method( - self.create_intent, - default_timeout=None, - client_info=client_info, - ), - self.update_intent: gapic_v1.method.wrap_method( - self.update_intent, - default_timeout=None, - client_info=client_info, - ), - self.delete_intent: gapic_v1.method.wrap_method( - self.delete_intent, - 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 list_intents(self) -> Callable[ - [intent.ListIntentsRequest], - Union[ - intent.ListIntentsResponse, - Awaitable[intent.ListIntentsResponse] - ]]: - raise NotImplementedError() - - @property - def get_intent(self) -> Callable[ - [intent.GetIntentRequest], - Union[ - intent.Intent, - Awaitable[intent.Intent] - ]]: - raise NotImplementedError() - - @property - def create_intent(self) -> Callable[ - [gcdc_intent.CreateIntentRequest], - Union[ - gcdc_intent.Intent, - Awaitable[gcdc_intent.Intent] - ]]: - raise NotImplementedError() - - @property - def update_intent(self) -> Callable[ - [gcdc_intent.UpdateIntentRequest], - Union[ - gcdc_intent.Intent, - Awaitable[gcdc_intent.Intent] - ]]: - raise NotImplementedError() - - @property - def delete_intent(self) -> Callable[ - [intent.DeleteIntentRequest], - 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 get_location(self, - ) -> Callable[ - [locations_pb2.GetLocationRequest], - Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], - ]: - raise NotImplementedError() - - @property - def list_locations(self, - ) -> Callable[ - [locations_pb2.ListLocationsRequest], - Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'IntentsTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/transports/grpc.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/transports/grpc.py deleted file mode 100644 index 7f2f2b9d..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/transports/grpc.py +++ /dev/null @@ -1,476 +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 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.dialogflowcx_v3.types import intent -from google.cloud.dialogflowcx_v3.types import intent as gcdc_intent -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from .base import IntentsTransport, DEFAULT_CLIENT_INFO - - -class IntentsGrpcTransport(IntentsTransport): - """gRPC backend transport for Intents. - - Service for managing - [Intents][google.cloud.dialogflow.cx.v3.Intent]. - - 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 = 'dialogflow.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] = {} - - 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 = 'dialogflow.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 list_intents(self) -> Callable[ - [intent.ListIntentsRequest], - intent.ListIntentsResponse]: - r"""Return a callable for the list intents method over gRPC. - - Returns the list of all intents in the specified - agent. - - Returns: - Callable[[~.ListIntentsRequest], - ~.ListIntentsResponse]: - 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_intents' not in self._stubs: - self._stubs['list_intents'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Intents/ListIntents', - request_serializer=intent.ListIntentsRequest.serialize, - response_deserializer=intent.ListIntentsResponse.deserialize, - ) - return self._stubs['list_intents'] - - @property - def get_intent(self) -> Callable[ - [intent.GetIntentRequest], - intent.Intent]: - r"""Return a callable for the get intent method over gRPC. - - Retrieves the specified intent. - - Returns: - Callable[[~.GetIntentRequest], - ~.Intent]: - 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_intent' not in self._stubs: - self._stubs['get_intent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Intents/GetIntent', - request_serializer=intent.GetIntentRequest.serialize, - response_deserializer=intent.Intent.deserialize, - ) - return self._stubs['get_intent'] - - @property - def create_intent(self) -> Callable[ - [gcdc_intent.CreateIntentRequest], - gcdc_intent.Intent]: - r"""Return a callable for the create intent method over gRPC. - - Creates an intent in the specified agent. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.CreateIntentRequest], - ~.Intent]: - 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_intent' not in self._stubs: - self._stubs['create_intent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Intents/CreateIntent', - request_serializer=gcdc_intent.CreateIntentRequest.serialize, - response_deserializer=gcdc_intent.Intent.deserialize, - ) - return self._stubs['create_intent'] - - @property - def update_intent(self) -> Callable[ - [gcdc_intent.UpdateIntentRequest], - gcdc_intent.Intent]: - r"""Return a callable for the update intent method over gRPC. - - Updates the specified intent. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.UpdateIntentRequest], - ~.Intent]: - 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_intent' not in self._stubs: - self._stubs['update_intent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Intents/UpdateIntent', - request_serializer=gcdc_intent.UpdateIntentRequest.serialize, - response_deserializer=gcdc_intent.Intent.deserialize, - ) - return self._stubs['update_intent'] - - @property - def delete_intent(self) -> Callable[ - [intent.DeleteIntentRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete intent method over gRPC. - - Deletes the specified intent. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.DeleteIntentRequest], - ~.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_intent' not in self._stubs: - self._stubs['delete_intent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Intents/DeleteIntent', - request_serializer=intent.DeleteIntentRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_intent'] - - 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 list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'IntentsGrpcTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/transports/grpc_asyncio.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/transports/grpc_asyncio.py deleted file mode 100644 index 3b4af081..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/transports/grpc_asyncio.py +++ /dev/null @@ -1,475 +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.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.dialogflowcx_v3.types import intent -from google.cloud.dialogflowcx_v3.types import intent as gcdc_intent -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from .base import IntentsTransport, DEFAULT_CLIENT_INFO -from .grpc import IntentsGrpcTransport - - -class IntentsGrpcAsyncIOTransport(IntentsTransport): - """gRPC AsyncIO backend transport for Intents. - - Service for managing - [Intents][google.cloud.dialogflow.cx.v3.Intent]. - - 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 = 'dialogflow.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 = 'dialogflow.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] = {} - - 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 list_intents(self) -> Callable[ - [intent.ListIntentsRequest], - Awaitable[intent.ListIntentsResponse]]: - r"""Return a callable for the list intents method over gRPC. - - Returns the list of all intents in the specified - agent. - - Returns: - Callable[[~.ListIntentsRequest], - Awaitable[~.ListIntentsResponse]]: - 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_intents' not in self._stubs: - self._stubs['list_intents'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Intents/ListIntents', - request_serializer=intent.ListIntentsRequest.serialize, - response_deserializer=intent.ListIntentsResponse.deserialize, - ) - return self._stubs['list_intents'] - - @property - def get_intent(self) -> Callable[ - [intent.GetIntentRequest], - Awaitable[intent.Intent]]: - r"""Return a callable for the get intent method over gRPC. - - Retrieves the specified intent. - - Returns: - Callable[[~.GetIntentRequest], - Awaitable[~.Intent]]: - 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_intent' not in self._stubs: - self._stubs['get_intent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Intents/GetIntent', - request_serializer=intent.GetIntentRequest.serialize, - response_deserializer=intent.Intent.deserialize, - ) - return self._stubs['get_intent'] - - @property - def create_intent(self) -> Callable[ - [gcdc_intent.CreateIntentRequest], - Awaitable[gcdc_intent.Intent]]: - r"""Return a callable for the create intent method over gRPC. - - Creates an intent in the specified agent. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.CreateIntentRequest], - Awaitable[~.Intent]]: - 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_intent' not in self._stubs: - self._stubs['create_intent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Intents/CreateIntent', - request_serializer=gcdc_intent.CreateIntentRequest.serialize, - response_deserializer=gcdc_intent.Intent.deserialize, - ) - return self._stubs['create_intent'] - - @property - def update_intent(self) -> Callable[ - [gcdc_intent.UpdateIntentRequest], - Awaitable[gcdc_intent.Intent]]: - r"""Return a callable for the update intent method over gRPC. - - Updates the specified intent. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.UpdateIntentRequest], - Awaitable[~.Intent]]: - 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_intent' not in self._stubs: - self._stubs['update_intent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Intents/UpdateIntent', - request_serializer=gcdc_intent.UpdateIntentRequest.serialize, - response_deserializer=gcdc_intent.Intent.deserialize, - ) - return self._stubs['update_intent'] - - @property - def delete_intent(self) -> Callable[ - [intent.DeleteIntentRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete intent method over gRPC. - - Deletes the specified intent. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.DeleteIntentRequest], - 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_intent' not in self._stubs: - self._stubs['delete_intent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Intents/DeleteIntent', - request_serializer=intent.DeleteIntentRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_intent'] - - 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"] - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - -__all__ = ( - 'IntentsGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/transports/rest.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/transports/rest.py deleted file mode 100644 index d76cb63c..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/intents/transports/rest.py +++ /dev/null @@ -1,1187 +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.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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.dialogflowcx_v3.types import intent -from google.cloud.dialogflowcx_v3.types import intent as gcdc_intent -from google.protobuf import empty_pb2 # type: ignore - -from .base import IntentsTransport, 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 IntentsRestInterceptor: - """Interceptor for Intents. - - 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 IntentsRestTransport. - - .. code-block:: python - class MyCustomIntentsInterceptor(IntentsRestInterceptor): - def pre_create_intent(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_intent(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_intent(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_get_intent(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_intent(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_intents(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_intents(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_intent(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_intent(self, response): - logging.log(f"Received response: {response}") - return response - - transport = IntentsRestTransport(interceptor=MyCustomIntentsInterceptor()) - client = IntentsClient(transport=transport) - - - """ - def pre_create_intent(self, request: gcdc_intent.CreateIntentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_intent.CreateIntentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_intent - - Override in a subclass to manipulate the request or metadata - before they are sent to the Intents server. - """ - return request, metadata - - def post_create_intent(self, response: gcdc_intent.Intent) -> gcdc_intent.Intent: - """Post-rpc interceptor for create_intent - - Override in a subclass to manipulate the response - after it is returned by the Intents server but before - it is returned to user code. - """ - return response - def pre_delete_intent(self, request: intent.DeleteIntentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[intent.DeleteIntentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_intent - - Override in a subclass to manipulate the request or metadata - before they are sent to the Intents server. - """ - return request, metadata - - def pre_get_intent(self, request: intent.GetIntentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[intent.GetIntentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_intent - - Override in a subclass to manipulate the request or metadata - before they are sent to the Intents server. - """ - return request, metadata - - def post_get_intent(self, response: intent.Intent) -> intent.Intent: - """Post-rpc interceptor for get_intent - - Override in a subclass to manipulate the response - after it is returned by the Intents server but before - it is returned to user code. - """ - return response - def pre_list_intents(self, request: intent.ListIntentsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[intent.ListIntentsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_intents - - Override in a subclass to manipulate the request or metadata - before they are sent to the Intents server. - """ - return request, metadata - - def post_list_intents(self, response: intent.ListIntentsResponse) -> intent.ListIntentsResponse: - """Post-rpc interceptor for list_intents - - Override in a subclass to manipulate the response - after it is returned by the Intents server but before - it is returned to user code. - """ - return response - def pre_update_intent(self, request: gcdc_intent.UpdateIntentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_intent.UpdateIntentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_intent - - Override in a subclass to manipulate the request or metadata - before they are sent to the Intents server. - """ - return request, metadata - - def post_update_intent(self, response: gcdc_intent.Intent) -> gcdc_intent.Intent: - """Post-rpc interceptor for update_intent - - Override in a subclass to manipulate the response - after it is returned by the Intents server but before - it is returned to user code. - """ - return response - - def pre_get_location( - self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_location - - Override in a subclass to manipulate the request or metadata - before they are sent to the Intents server. - """ - return request, metadata - - def post_get_location( - self, response: locations_pb2.Location - ) -> locations_pb2.Location: - """Post-rpc interceptor for get_location - - Override in a subclass to manipulate the response - after it is returned by the Intents server but before - it is returned to user code. - """ - return response - def pre_list_locations( - self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_locations - - Override in a subclass to manipulate the request or metadata - before they are sent to the Intents server. - """ - return request, metadata - - def post_list_locations( - self, response: locations_pb2.ListLocationsResponse - ) -> locations_pb2.ListLocationsResponse: - """Post-rpc interceptor for list_locations - - Override in a subclass to manipulate the response - after it is returned by the Intents 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 Intents 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 Intents 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 Intents 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 Intents 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 Intents 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 Intents server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class IntentsRestStub: - _session: AuthorizedSession - _host: str - _interceptor: IntentsRestInterceptor - - -class IntentsRestTransport(IntentsTransport): - """REST backend transport for Intents. - - Service for managing - [Intents][google.cloud.dialogflow.cx.v3.Intent]. - - 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 = 'dialogflow.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[IntentsRestInterceptor] = 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) - if client_cert_source_for_mtls: - self._session.configure_mtls_channel(client_cert_source_for_mtls) - self._interceptor = interceptor or IntentsRestInterceptor() - self._prep_wrapped_messages(client_info) - - class _CreateIntent(IntentsRestStub): - def __hash__(self): - return hash("CreateIntent") - - __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: gcdc_intent.CreateIntentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_intent.Intent: - r"""Call the create intent method over HTTP. - - Args: - request (~.gcdc_intent.CreateIntentRequest): - The request object. The request message for - [Intents.CreateIntent][google.cloud.dialogflow.cx.v3.Intents.CreateIntent]. - 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: - ~.gcdc_intent.Intent: - An intent represents a user's intent - to interact with a conversational agent. - You can provide information for the - Dialogflow API to use to match user - input to an intent by adding training - phrases (i.e., examples of user input) - to your intent. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*}/intents', - 'body': 'intent', - }, - ] - request, metadata = self._interceptor.pre_create_intent(request, metadata) - pb_request = gcdc_intent.CreateIntentRequest.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 = gcdc_intent.Intent() - pb_resp = gcdc_intent.Intent.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_intent(resp) - return resp - - class _DeleteIntent(IntentsRestStub): - def __hash__(self): - return hash("DeleteIntent") - - __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: intent.DeleteIntentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete intent method over HTTP. - - Args: - request (~.intent.DeleteIntentRequest): - The request object. The request message for - [Intents.DeleteIntent][google.cloud.dialogflow.cx.v3.Intents.DeleteIntent]. - 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': '/v3/{name=projects/*/locations/*/agents/*/intents/*}', - }, - ] - request, metadata = self._interceptor.pre_delete_intent(request, metadata) - pb_request = intent.DeleteIntentRequest.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 _GetIntent(IntentsRestStub): - def __hash__(self): - return hash("GetIntent") - - __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: intent.GetIntentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> intent.Intent: - r"""Call the get intent method over HTTP. - - Args: - request (~.intent.GetIntentRequest): - The request object. The request message for - [Intents.GetIntent][google.cloud.dialogflow.cx.v3.Intents.GetIntent]. - 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: - ~.intent.Intent: - An intent represents a user's intent - to interact with a conversational agent. - You can provide information for the - Dialogflow API to use to match user - input to an intent by adding training - phrases (i.e., examples of user input) - to your intent. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/intents/*}', - }, - ] - request, metadata = self._interceptor.pre_get_intent(request, metadata) - pb_request = intent.GetIntentRequest.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 = intent.Intent() - pb_resp = intent.Intent.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_intent(resp) - return resp - - class _ListIntents(IntentsRestStub): - def __hash__(self): - return hash("ListIntents") - - __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: intent.ListIntentsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> intent.ListIntentsResponse: - r"""Call the list intents method over HTTP. - - Args: - request (~.intent.ListIntentsRequest): - The request object. The request message for - [Intents.ListIntents][google.cloud.dialogflow.cx.v3.Intents.ListIntents]. - 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: - ~.intent.ListIntentsResponse: - The response message for - [Intents.ListIntents][google.cloud.dialogflow.cx.v3.Intents.ListIntents]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*}/intents', - }, - ] - request, metadata = self._interceptor.pre_list_intents(request, metadata) - pb_request = intent.ListIntentsRequest.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 = intent.ListIntentsResponse() - pb_resp = intent.ListIntentsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_intents(resp) - return resp - - class _UpdateIntent(IntentsRestStub): - def __hash__(self): - return hash("UpdateIntent") - - __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: gcdc_intent.UpdateIntentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_intent.Intent: - r"""Call the update intent method over HTTP. - - Args: - request (~.gcdc_intent.UpdateIntentRequest): - The request object. The request message for - [Intents.UpdateIntent][google.cloud.dialogflow.cx.v3.Intents.UpdateIntent]. - 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: - ~.gcdc_intent.Intent: - An intent represents a user's intent - to interact with a conversational agent. - You can provide information for the - Dialogflow API to use to match user - input to an intent by adding training - phrases (i.e., examples of user input) - to your intent. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v3/{intent.name=projects/*/locations/*/agents/*/intents/*}', - 'body': 'intent', - }, - ] - request, metadata = self._interceptor.pre_update_intent(request, metadata) - pb_request = gcdc_intent.UpdateIntentRequest.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 = gcdc_intent.Intent() - pb_resp = gcdc_intent.Intent.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_intent(resp) - return resp - - @property - def create_intent(self) -> Callable[ - [gcdc_intent.CreateIntentRequest], - gcdc_intent.Intent]: - # 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._CreateIntent(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_intent(self) -> Callable[ - [intent.DeleteIntentRequest], - 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._DeleteIntent(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_intent(self) -> Callable[ - [intent.GetIntentRequest], - intent.Intent]: - # 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._GetIntent(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_intents(self) -> Callable[ - [intent.ListIntentsRequest], - intent.ListIntentsResponse]: - # 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._ListIntents(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_intent(self) -> Callable[ - [gcdc_intent.UpdateIntentRequest], - gcdc_intent.Intent]: - # 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._UpdateIntent(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_location(self): - return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore - - class _GetLocation(IntentsRestStub): - def __call__(self, - request: locations_pb2.GetLocationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.Location: - - r"""Call the get location method over HTTP. - - Args: - request (locations_pb2.GetLocationRequest): - The request object for GetLocation 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: - locations_pb2.Location: Response from GetLocation method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*}', - }, - ] - - request, metadata = self._interceptor.pre_get_location(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 = locations_pb2.Location() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_get_location(resp) - return resp - - @property - def list_locations(self): - return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore - - class _ListLocations(IntentsRestStub): - def __call__(self, - request: locations_pb2.ListLocationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.ListLocationsResponse: - - r"""Call the list locations method over HTTP. - - Args: - request (locations_pb2.ListLocationsRequest): - The request object for ListLocations 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: - locations_pb2.ListLocationsResponse: Response from ListLocations method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*}/locations', - }, - ] - - request, metadata = self._interceptor.pre_list_locations(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 = locations_pb2.ListLocationsResponse() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_list_locations(resp) - return resp - - @property - def cancel_operation(self): - return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore - - class _CancelOperation(IntentsRestStub): - 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': '/v3/{name=projects/*/operations/*}:cancel', - }, -{ - 'method': 'post', - 'uri': '/v3/{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(IntentsRestStub): - 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': '/v3/{name=projects/*/operations/*}', - }, -{ - 'method': 'get', - 'uri': '/v3/{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(IntentsRestStub): - 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': '/v3/{name=projects/*}/operations', - }, -{ - 'method': 'get', - 'uri': '/v3/{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__=( - 'IntentsRestTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/__init__.py deleted file mode 100644 index ab288838..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/__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 PagesClient -from .async_client import PagesAsyncClient - -__all__ = ( - 'PagesClient', - 'PagesAsyncClient', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/async_client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/async_client.py deleted file mode 100644 index caf98e6d..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/async_client.py +++ /dev/null @@ -1,1069 +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.dialogflowcx_v3 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.cloud.dialogflowcx_v3.services.pages import pagers -from google.cloud.dialogflowcx_v3.types import fulfillment -from google.cloud.dialogflowcx_v3.types import page -from google.cloud.dialogflowcx_v3.types import page as gcdc_page -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import PagesTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import PagesGrpcAsyncIOTransport -from .client import PagesClient - - -class PagesAsyncClient: - """Service for managing [Pages][google.cloud.dialogflow.cx.v3.Page].""" - - _client: PagesClient - - DEFAULT_ENDPOINT = PagesClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = PagesClient.DEFAULT_MTLS_ENDPOINT - - entity_type_path = staticmethod(PagesClient.entity_type_path) - parse_entity_type_path = staticmethod(PagesClient.parse_entity_type_path) - flow_path = staticmethod(PagesClient.flow_path) - parse_flow_path = staticmethod(PagesClient.parse_flow_path) - intent_path = staticmethod(PagesClient.intent_path) - parse_intent_path = staticmethod(PagesClient.parse_intent_path) - page_path = staticmethod(PagesClient.page_path) - parse_page_path = staticmethod(PagesClient.parse_page_path) - transition_route_group_path = staticmethod(PagesClient.transition_route_group_path) - parse_transition_route_group_path = staticmethod(PagesClient.parse_transition_route_group_path) - webhook_path = staticmethod(PagesClient.webhook_path) - parse_webhook_path = staticmethod(PagesClient.parse_webhook_path) - common_billing_account_path = staticmethod(PagesClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(PagesClient.parse_common_billing_account_path) - common_folder_path = staticmethod(PagesClient.common_folder_path) - parse_common_folder_path = staticmethod(PagesClient.parse_common_folder_path) - common_organization_path = staticmethod(PagesClient.common_organization_path) - parse_common_organization_path = staticmethod(PagesClient.parse_common_organization_path) - common_project_path = staticmethod(PagesClient.common_project_path) - parse_common_project_path = staticmethod(PagesClient.parse_common_project_path) - common_location_path = staticmethod(PagesClient.common_location_path) - parse_common_location_path = staticmethod(PagesClient.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: - PagesAsyncClient: The constructed client. - """ - return PagesClient.from_service_account_info.__func__(PagesAsyncClient, 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: - PagesAsyncClient: The constructed client. - """ - return PagesClient.from_service_account_file.__func__(PagesAsyncClient, 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 PagesClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> PagesTransport: - """Returns the transport used by the client instance. - - Returns: - PagesTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(PagesClient).get_transport_class, type(PagesClient)) - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, PagesTransport] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the pages 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, ~.PagesTransport]): 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 = PagesClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def list_pages(self, - request: Optional[Union[page.ListPagesRequest, 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.ListPagesAsyncPager: - r"""Returns the list of all pages in the specified flow. - - .. 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 dialogflowcx_v3 - - async def sample_list_pages(): - # Create a client - client = dialogflowcx_v3.PagesAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListPagesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_pages(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ListPagesRequest, dict]]): - The request object. The request message for - [Pages.ListPages][google.cloud.dialogflow.cx.v3.Pages.ListPages]. - parent (:class:`str`): - Required. The flow to list all pages for. Format: - ``projects//locations//agents//flows/``. - - 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.dialogflowcx_v3.services.pages.pagers.ListPagesAsyncPager: - The response message for - [Pages.ListPages][google.cloud.dialogflow.cx.v3.Pages.ListPages]. - - 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 = page.ListPagesRequest(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_pages, - 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.ListPagesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_page(self, - request: Optional[Union[page.GetPageRequest, 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]] = (), - ) -> page.Page: - r"""Retrieves the specified page. - - .. 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 dialogflowcx_v3 - - async def sample_get_page(): - # Create a client - client = dialogflowcx_v3.PagesAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetPageRequest( - name="name_value", - ) - - # Make the request - response = await client.get_page(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.GetPageRequest, dict]]): - The request object. The request message for - [Pages.GetPage][google.cloud.dialogflow.cx.v3.Pages.GetPage]. - name (:class:`str`): - Required. The name of the page. Format: - ``projects//locations//agents//flows//pages/``. - - 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.dialogflowcx_v3.types.Page: - A Dialogflow CX conversation (session) can be described and visualized as a - state machine. The states of a CX session are - represented by pages. - - For each flow, you define many pages, where your - combined pages can handle a complete conversation on - the topics the flow is designed for. At any given - moment, exactly one page is the current page, the - current page is considered active, and the flow - associated with that page is considered active. Every - flow has a special start page. When a flow initially - becomes active, the start page page becomes the - current page. For each conversational turn, the - current page will either stay the same or transition - to another page. - - You configure each page to collect information from - the end-user that is relevant for the conversational - state represented by the page. - - For more information, see the [Page - guide](\ https://cloud.google.com/dialogflow/cx/docs/concept/page). - - """ - # 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 = page.GetPageRequest(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_page, - 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 create_page(self, - request: Optional[Union[gcdc_page.CreatePageRequest, dict]] = None, - *, - parent: Optional[str] = None, - page: Optional[gcdc_page.Page] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_page.Page: - r"""Creates a page in the specified flow. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - async def sample_create_page(): - # Create a client - client = dialogflowcx_v3.PagesAsyncClient() - - # Initialize request argument(s) - page = dialogflowcx_v3.Page() - page.display_name = "display_name_value" - - request = dialogflowcx_v3.CreatePageRequest( - parent="parent_value", - page=page, - ) - - # Make the request - response = await client.create_page(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.CreatePageRequest, dict]]): - The request object. The request message for - [Pages.CreatePage][google.cloud.dialogflow.cx.v3.Pages.CreatePage]. - parent (:class:`str`): - Required. The flow to create a page for. Format: - ``projects//locations//agents//flows/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - page (:class:`google.cloud.dialogflowcx_v3.types.Page`): - Required. The page to create. - This corresponds to the ``page`` 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.dialogflowcx_v3.types.Page: - A Dialogflow CX conversation (session) can be described and visualized as a - state machine. The states of a CX session are - represented by pages. - - For each flow, you define many pages, where your - combined pages can handle a complete conversation on - the topics the flow is designed for. At any given - moment, exactly one page is the current page, the - current page is considered active, and the flow - associated with that page is considered active. Every - flow has a special start page. When a flow initially - becomes active, the start page page becomes the - current page. For each conversational turn, the - current page will either stay the same or transition - to another page. - - You configure each page to collect information from - the end-user that is relevant for the conversational - state represented by the page. - - For more information, see the [Page - guide](\ https://cloud.google.com/dialogflow/cx/docs/concept/page). - - """ - # 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, page]) - 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 = gcdc_page.CreatePageRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if page is not None: - request.page = page - - # 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_page, - 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_page(self, - request: Optional[Union[gcdc_page.UpdatePageRequest, dict]] = None, - *, - page: Optional[gcdc_page.Page] = 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]] = (), - ) -> gcdc_page.Page: - r"""Updates the specified page. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - async def sample_update_page(): - # Create a client - client = dialogflowcx_v3.PagesAsyncClient() - - # Initialize request argument(s) - page = dialogflowcx_v3.Page() - page.display_name = "display_name_value" - - request = dialogflowcx_v3.UpdatePageRequest( - page=page, - ) - - # Make the request - response = await client.update_page(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.UpdatePageRequest, dict]]): - The request object. The request message for - [Pages.UpdatePage][google.cloud.dialogflow.cx.v3.Pages.UpdatePage]. - page (:class:`google.cloud.dialogflowcx_v3.types.Page`): - Required. The page to update. - This corresponds to the ``page`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The mask to control which fields get - updated. If the mask is not present, all - fields will 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.dialogflowcx_v3.types.Page: - A Dialogflow CX conversation (session) can be described and visualized as a - state machine. The states of a CX session are - represented by pages. - - For each flow, you define many pages, where your - combined pages can handle a complete conversation on - the topics the flow is designed for. At any given - moment, exactly one page is the current page, the - current page is considered active, and the flow - associated with that page is considered active. Every - flow has a special start page. When a flow initially - becomes active, the start page page becomes the - current page. For each conversational turn, the - current page will either stay the same or transition - to another page. - - You configure each page to collect information from - the end-user that is relevant for the conversational - state represented by the page. - - For more information, see the [Page - guide](\ https://cloud.google.com/dialogflow/cx/docs/concept/page). - - """ - # 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([page, 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 = gcdc_page.UpdatePageRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if page is not None: - request.page = page - 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_page, - 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(( - ("page.name", request.page.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_page(self, - request: Optional[Union[page.DeletePageRequest, 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 the specified page. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - async def sample_delete_page(): - # Create a client - client = dialogflowcx_v3.PagesAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeletePageRequest( - name="name_value", - ) - - # Make the request - await client.delete_page(request=request) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.DeletePageRequest, dict]]): - The request object. The request message for - [Pages.DeletePage][google.cloud.dialogflow.cx.v3.Pages.DeletePage]. - name (:class:`str`): - Required. The name of the page to delete. Format: - ``projects//locations//agents//Flows//pages/``. - - 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 = page.DeletePageRequest(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_page, - 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 get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**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_location, - 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_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**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_locations, - 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 __aenter__(self) -> "PagesAsyncClient": - 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__ = ( - "PagesAsyncClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/client.py deleted file mode 100644 index a0377ad2..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/client.py +++ /dev/null @@ -1,1313 +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.dialogflowcx_v3 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.cloud.dialogflowcx_v3.services.pages import pagers -from google.cloud.dialogflowcx_v3.types import fulfillment -from google.cloud.dialogflowcx_v3.types import page -from google.cloud.dialogflowcx_v3.types import page as gcdc_page -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import PagesTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import PagesGrpcTransport -from .transports.grpc_asyncio import PagesGrpcAsyncIOTransport -from .transports.rest import PagesRestTransport - - -class PagesClientMeta(type): - """Metaclass for the Pages 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[PagesTransport]] - _transport_registry["grpc"] = PagesGrpcTransport - _transport_registry["grpc_asyncio"] = PagesGrpcAsyncIOTransport - _transport_registry["rest"] = PagesRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[PagesTransport]: - """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 PagesClient(metaclass=PagesClientMeta): - """Service for managing [Pages][google.cloud.dialogflow.cx.v3.Page].""" - - @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 = "dialogflow.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: - PagesClient: 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: - PagesClient: 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) -> PagesTransport: - """Returns the transport used by the client instance. - - Returns: - PagesTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def entity_type_path(project: str,location: str,agent: str,entity_type: str,) -> str: - """Returns a fully-qualified entity_type string.""" - return "projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type}".format(project=project, location=location, agent=agent, entity_type=entity_type, ) - - @staticmethod - def parse_entity_type_path(path: str) -> Dict[str,str]: - """Parses a entity_type path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/entityTypes/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def flow_path(project: str,location: str,agent: str,flow: str,) -> str: - """Returns a fully-qualified flow string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}".format(project=project, location=location, agent=agent, flow=flow, ) - - @staticmethod - def parse_flow_path(path: str) -> Dict[str,str]: - """Parses a flow path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def intent_path(project: str,location: str,agent: str,intent: str,) -> str: - """Returns a fully-qualified intent string.""" - return "projects/{project}/locations/{location}/agents/{agent}/intents/{intent}".format(project=project, location=location, agent=agent, intent=intent, ) - - @staticmethod - def parse_intent_path(path: str) -> Dict[str,str]: - """Parses a intent path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/intents/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def page_path(project: str,location: str,agent: str,flow: str,page: str,) -> str: - """Returns a fully-qualified page string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page}".format(project=project, location=location, agent=agent, flow=flow, page=page, ) - - @staticmethod - def parse_page_path(path: str) -> Dict[str,str]: - """Parses a page path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)/pages/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def transition_route_group_path(project: str,location: str,agent: str,flow: str,transition_route_group: str,) -> str: - """Returns a fully-qualified transition_route_group string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}".format(project=project, location=location, agent=agent, flow=flow, transition_route_group=transition_route_group, ) - - @staticmethod - def parse_transition_route_group_path(path: str) -> Dict[str,str]: - """Parses a transition_route_group path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)/transitionRouteGroups/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def webhook_path(project: str,location: str,agent: str,webhook: str,) -> str: - """Returns a fully-qualified webhook string.""" - return "projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}".format(project=project, location=location, agent=agent, webhook=webhook, ) - - @staticmethod - def parse_webhook_path(path: str) -> Dict[str,str]: - """Parses a webhook path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/webhooks/(?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, PagesTransport]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the pages 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, PagesTransport]): 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, PagesTransport): - # transport is a PagesTransport 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 list_pages(self, - request: Optional[Union[page.ListPagesRequest, 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.ListPagesPager: - r"""Returns the list of all pages in the specified flow. - - .. 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 dialogflowcx_v3 - - def sample_list_pages(): - # Create a client - client = dialogflowcx_v3.PagesClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListPagesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_pages(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ListPagesRequest, dict]): - The request object. The request message for - [Pages.ListPages][google.cloud.dialogflow.cx.v3.Pages.ListPages]. - parent (str): - Required. The flow to list all pages for. Format: - ``projects//locations//agents//flows/``. - - 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.dialogflowcx_v3.services.pages.pagers.ListPagesPager: - The response message for - [Pages.ListPages][google.cloud.dialogflow.cx.v3.Pages.ListPages]. - - 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 page.ListPagesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, page.ListPagesRequest): - request = page.ListPagesRequest(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_pages] - - # 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.ListPagesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_page(self, - request: Optional[Union[page.GetPageRequest, 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]] = (), - ) -> page.Page: - r"""Retrieves the specified page. - - .. 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 dialogflowcx_v3 - - def sample_get_page(): - # Create a client - client = dialogflowcx_v3.PagesClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetPageRequest( - name="name_value", - ) - - # Make the request - response = client.get_page(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.GetPageRequest, dict]): - The request object. The request message for - [Pages.GetPage][google.cloud.dialogflow.cx.v3.Pages.GetPage]. - name (str): - Required. The name of the page. Format: - ``projects//locations//agents//flows//pages/``. - - 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.dialogflowcx_v3.types.Page: - A Dialogflow CX conversation (session) can be described and visualized as a - state machine. The states of a CX session are - represented by pages. - - For each flow, you define many pages, where your - combined pages can handle a complete conversation on - the topics the flow is designed for. At any given - moment, exactly one page is the current page, the - current page is considered active, and the flow - associated with that page is considered active. Every - flow has a special start page. When a flow initially - becomes active, the start page page becomes the - current page. For each conversational turn, the - current page will either stay the same or transition - to another page. - - You configure each page to collect information from - the end-user that is relevant for the conversational - state represented by the page. - - For more information, see the [Page - guide](\ https://cloud.google.com/dialogflow/cx/docs/concept/page). - - """ - # 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 page.GetPageRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, page.GetPageRequest): - request = page.GetPageRequest(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_page] - - # 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 create_page(self, - request: Optional[Union[gcdc_page.CreatePageRequest, dict]] = None, - *, - parent: Optional[str] = None, - page: Optional[gcdc_page.Page] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_page.Page: - r"""Creates a page in the specified flow. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - def sample_create_page(): - # Create a client - client = dialogflowcx_v3.PagesClient() - - # Initialize request argument(s) - page = dialogflowcx_v3.Page() - page.display_name = "display_name_value" - - request = dialogflowcx_v3.CreatePageRequest( - parent="parent_value", - page=page, - ) - - # Make the request - response = client.create_page(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.CreatePageRequest, dict]): - The request object. The request message for - [Pages.CreatePage][google.cloud.dialogflow.cx.v3.Pages.CreatePage]. - parent (str): - Required. The flow to create a page for. Format: - ``projects//locations//agents//flows/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - page (google.cloud.dialogflowcx_v3.types.Page): - Required. The page to create. - This corresponds to the ``page`` 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.dialogflowcx_v3.types.Page: - A Dialogflow CX conversation (session) can be described and visualized as a - state machine. The states of a CX session are - represented by pages. - - For each flow, you define many pages, where your - combined pages can handle a complete conversation on - the topics the flow is designed for. At any given - moment, exactly one page is the current page, the - current page is considered active, and the flow - associated with that page is considered active. Every - flow has a special start page. When a flow initially - becomes active, the start page page becomes the - current page. For each conversational turn, the - current page will either stay the same or transition - to another page. - - You configure each page to collect information from - the end-user that is relevant for the conversational - state represented by the page. - - For more information, see the [Page - guide](\ https://cloud.google.com/dialogflow/cx/docs/concept/page). - - """ - # 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, page]) - 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 gcdc_page.CreatePageRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_page.CreatePageRequest): - request = gcdc_page.CreatePageRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if page is not None: - request.page = page - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_page] - - # 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_page(self, - request: Optional[Union[gcdc_page.UpdatePageRequest, dict]] = None, - *, - page: Optional[gcdc_page.Page] = 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]] = (), - ) -> gcdc_page.Page: - r"""Updates the specified page. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - def sample_update_page(): - # Create a client - client = dialogflowcx_v3.PagesClient() - - # Initialize request argument(s) - page = dialogflowcx_v3.Page() - page.display_name = "display_name_value" - - request = dialogflowcx_v3.UpdatePageRequest( - page=page, - ) - - # Make the request - response = client.update_page(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.UpdatePageRequest, dict]): - The request object. The request message for - [Pages.UpdatePage][google.cloud.dialogflow.cx.v3.Pages.UpdatePage]. - page (google.cloud.dialogflowcx_v3.types.Page): - Required. The page to update. - This corresponds to the ``page`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The mask to control which fields get - updated. If the mask is not present, all - fields will 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.dialogflowcx_v3.types.Page: - A Dialogflow CX conversation (session) can be described and visualized as a - state machine. The states of a CX session are - represented by pages. - - For each flow, you define many pages, where your - combined pages can handle a complete conversation on - the topics the flow is designed for. At any given - moment, exactly one page is the current page, the - current page is considered active, and the flow - associated with that page is considered active. Every - flow has a special start page. When a flow initially - becomes active, the start page page becomes the - current page. For each conversational turn, the - current page will either stay the same or transition - to another page. - - You configure each page to collect information from - the end-user that is relevant for the conversational - state represented by the page. - - For more information, see the [Page - guide](\ https://cloud.google.com/dialogflow/cx/docs/concept/page). - - """ - # 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([page, 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 gcdc_page.UpdatePageRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_page.UpdatePageRequest): - request = gcdc_page.UpdatePageRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if page is not None: - request.page = page - 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_page] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("page.name", request.page.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_page(self, - request: Optional[Union[page.DeletePageRequest, 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 the specified page. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - def sample_delete_page(): - # Create a client - client = dialogflowcx_v3.PagesClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeletePageRequest( - name="name_value", - ) - - # Make the request - client.delete_page(request=request) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.DeletePageRequest, dict]): - The request object. The request message for - [Pages.DeletePage][google.cloud.dialogflow.cx.v3.Pages.DeletePage]. - name (str): - Required. The name of the page to delete. Format: - ``projects//locations//agents//Flows//pages/``. - - 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 page.DeletePageRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, page.DeletePageRequest): - request = page.DeletePageRequest(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_page] - - # 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) -> "PagesClient": - 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,) - - def get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.get_location, - 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 list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.list_locations, - 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 - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "PagesClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/pagers.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/pagers.py deleted file mode 100644 index 0a2d42f3..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/pagers.py +++ /dev/null @@ -1,139 +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.dialogflowcx_v3.types import page - - -class ListPagesPager: - """A pager for iterating through ``list_pages`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListPagesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``pages`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListPages`` requests and continue to iterate - through the ``pages`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListPagesResponse` - 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[..., page.ListPagesResponse], - request: page.ListPagesRequest, - response: page.ListPagesResponse, - *, - 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.dialogflowcx_v3.types.ListPagesRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListPagesResponse): - 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 = page.ListPagesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[page.ListPagesResponse]: - 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[page.Page]: - for page in self.pages: - yield from page.pages - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListPagesAsyncPager: - """A pager for iterating through ``list_pages`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListPagesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``pages`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListPages`` requests and continue to iterate - through the ``pages`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListPagesResponse` - 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[page.ListPagesResponse]], - request: page.ListPagesRequest, - response: page.ListPagesResponse, - *, - 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.dialogflowcx_v3.types.ListPagesRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListPagesResponse): - 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 = page.ListPagesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[page.ListPagesResponse]: - 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[page.Page]: - async def async_generator(): - async for page in self.pages: - for response in page.pages: - 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/v3/google/cloud/dialogflowcx_v3/services/pages/transports/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/transports/__init__.py deleted file mode 100644 index fcfe618b..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/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 PagesTransport -from .grpc import PagesGrpcTransport -from .grpc_asyncio import PagesGrpcAsyncIOTransport -from .rest import PagesRestTransport -from .rest import PagesRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[PagesTransport]] -_transport_registry['grpc'] = PagesGrpcTransport -_transport_registry['grpc_asyncio'] = PagesGrpcAsyncIOTransport -_transport_registry['rest'] = PagesRestTransport - -__all__ = ( - 'PagesTransport', - 'PagesGrpcTransport', - 'PagesGrpcAsyncIOTransport', - 'PagesRestTransport', - 'PagesRestInterceptor', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/transports/base.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/transports/base.py deleted file mode 100644 index 4e75cb82..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/transports/base.py +++ /dev/null @@ -1,252 +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.dialogflowcx_v3 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.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.dialogflowcx_v3.types import page -from google.cloud.dialogflowcx_v3.types import page as gcdc_page -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -class PagesTransport(abc.ABC): - """Abstract transport class for Pages.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/dialogflow', - ) - - DEFAULT_HOST: str = 'dialogflow.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.list_pages: gapic_v1.method.wrap_method( - self.list_pages, - default_timeout=None, - client_info=client_info, - ), - self.get_page: gapic_v1.method.wrap_method( - self.get_page, - default_timeout=None, - client_info=client_info, - ), - self.create_page: gapic_v1.method.wrap_method( - self.create_page, - default_timeout=None, - client_info=client_info, - ), - self.update_page: gapic_v1.method.wrap_method( - self.update_page, - default_timeout=None, - client_info=client_info, - ), - self.delete_page: gapic_v1.method.wrap_method( - self.delete_page, - 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 list_pages(self) -> Callable[ - [page.ListPagesRequest], - Union[ - page.ListPagesResponse, - Awaitable[page.ListPagesResponse] - ]]: - raise NotImplementedError() - - @property - def get_page(self) -> Callable[ - [page.GetPageRequest], - Union[ - page.Page, - Awaitable[page.Page] - ]]: - raise NotImplementedError() - - @property - def create_page(self) -> Callable[ - [gcdc_page.CreatePageRequest], - Union[ - gcdc_page.Page, - Awaitable[gcdc_page.Page] - ]]: - raise NotImplementedError() - - @property - def update_page(self) -> Callable[ - [gcdc_page.UpdatePageRequest], - Union[ - gcdc_page.Page, - Awaitable[gcdc_page.Page] - ]]: - raise NotImplementedError() - - @property - def delete_page(self) -> Callable[ - [page.DeletePageRequest], - 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 get_location(self, - ) -> Callable[ - [locations_pb2.GetLocationRequest], - Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], - ]: - raise NotImplementedError() - - @property - def list_locations(self, - ) -> Callable[ - [locations_pb2.ListLocationsRequest], - Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'PagesTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/transports/grpc.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/transports/grpc.py deleted file mode 100644 index fe04bc3c..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/transports/grpc.py +++ /dev/null @@ -1,474 +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 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.dialogflowcx_v3.types import page -from google.cloud.dialogflowcx_v3.types import page as gcdc_page -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from .base import PagesTransport, DEFAULT_CLIENT_INFO - - -class PagesGrpcTransport(PagesTransport): - """gRPC backend transport for Pages. - - Service for managing [Pages][google.cloud.dialogflow.cx.v3.Page]. - - 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 = 'dialogflow.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] = {} - - 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 = 'dialogflow.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 list_pages(self) -> Callable[ - [page.ListPagesRequest], - page.ListPagesResponse]: - r"""Return a callable for the list pages method over gRPC. - - Returns the list of all pages in the specified flow. - - Returns: - Callable[[~.ListPagesRequest], - ~.ListPagesResponse]: - 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_pages' not in self._stubs: - self._stubs['list_pages'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Pages/ListPages', - request_serializer=page.ListPagesRequest.serialize, - response_deserializer=page.ListPagesResponse.deserialize, - ) - return self._stubs['list_pages'] - - @property - def get_page(self) -> Callable[ - [page.GetPageRequest], - page.Page]: - r"""Return a callable for the get page method over gRPC. - - Retrieves the specified page. - - Returns: - Callable[[~.GetPageRequest], - ~.Page]: - 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_page' not in self._stubs: - self._stubs['get_page'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Pages/GetPage', - request_serializer=page.GetPageRequest.serialize, - response_deserializer=page.Page.deserialize, - ) - return self._stubs['get_page'] - - @property - def create_page(self) -> Callable[ - [gcdc_page.CreatePageRequest], - gcdc_page.Page]: - r"""Return a callable for the create page method over gRPC. - - Creates a page in the specified flow. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.CreatePageRequest], - ~.Page]: - 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_page' not in self._stubs: - self._stubs['create_page'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Pages/CreatePage', - request_serializer=gcdc_page.CreatePageRequest.serialize, - response_deserializer=gcdc_page.Page.deserialize, - ) - return self._stubs['create_page'] - - @property - def update_page(self) -> Callable[ - [gcdc_page.UpdatePageRequest], - gcdc_page.Page]: - r"""Return a callable for the update page method over gRPC. - - Updates the specified page. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.UpdatePageRequest], - ~.Page]: - 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_page' not in self._stubs: - self._stubs['update_page'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Pages/UpdatePage', - request_serializer=gcdc_page.UpdatePageRequest.serialize, - response_deserializer=gcdc_page.Page.deserialize, - ) - return self._stubs['update_page'] - - @property - def delete_page(self) -> Callable[ - [page.DeletePageRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete page method over gRPC. - - Deletes the specified page. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.DeletePageRequest], - ~.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_page' not in self._stubs: - self._stubs['delete_page'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Pages/DeletePage', - request_serializer=page.DeletePageRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_page'] - - 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 list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'PagesGrpcTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/transports/grpc_asyncio.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/transports/grpc_asyncio.py deleted file mode 100644 index b41028f1..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/transports/grpc_asyncio.py +++ /dev/null @@ -1,473 +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.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.dialogflowcx_v3.types import page -from google.cloud.dialogflowcx_v3.types import page as gcdc_page -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from .base import PagesTransport, DEFAULT_CLIENT_INFO -from .grpc import PagesGrpcTransport - - -class PagesGrpcAsyncIOTransport(PagesTransport): - """gRPC AsyncIO backend transport for Pages. - - Service for managing [Pages][google.cloud.dialogflow.cx.v3.Page]. - - 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 = 'dialogflow.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 = 'dialogflow.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] = {} - - 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 list_pages(self) -> Callable[ - [page.ListPagesRequest], - Awaitable[page.ListPagesResponse]]: - r"""Return a callable for the list pages method over gRPC. - - Returns the list of all pages in the specified flow. - - Returns: - Callable[[~.ListPagesRequest], - Awaitable[~.ListPagesResponse]]: - 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_pages' not in self._stubs: - self._stubs['list_pages'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Pages/ListPages', - request_serializer=page.ListPagesRequest.serialize, - response_deserializer=page.ListPagesResponse.deserialize, - ) - return self._stubs['list_pages'] - - @property - def get_page(self) -> Callable[ - [page.GetPageRequest], - Awaitable[page.Page]]: - r"""Return a callable for the get page method over gRPC. - - Retrieves the specified page. - - Returns: - Callable[[~.GetPageRequest], - Awaitable[~.Page]]: - 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_page' not in self._stubs: - self._stubs['get_page'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Pages/GetPage', - request_serializer=page.GetPageRequest.serialize, - response_deserializer=page.Page.deserialize, - ) - return self._stubs['get_page'] - - @property - def create_page(self) -> Callable[ - [gcdc_page.CreatePageRequest], - Awaitable[gcdc_page.Page]]: - r"""Return a callable for the create page method over gRPC. - - Creates a page in the specified flow. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.CreatePageRequest], - Awaitable[~.Page]]: - 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_page' not in self._stubs: - self._stubs['create_page'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Pages/CreatePage', - request_serializer=gcdc_page.CreatePageRequest.serialize, - response_deserializer=gcdc_page.Page.deserialize, - ) - return self._stubs['create_page'] - - @property - def update_page(self) -> Callable[ - [gcdc_page.UpdatePageRequest], - Awaitable[gcdc_page.Page]]: - r"""Return a callable for the update page method over gRPC. - - Updates the specified page. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.UpdatePageRequest], - Awaitable[~.Page]]: - 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_page' not in self._stubs: - self._stubs['update_page'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Pages/UpdatePage', - request_serializer=gcdc_page.UpdatePageRequest.serialize, - response_deserializer=gcdc_page.Page.deserialize, - ) - return self._stubs['update_page'] - - @property - def delete_page(self) -> Callable[ - [page.DeletePageRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete page method over gRPC. - - Deletes the specified page. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.DeletePageRequest], - 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_page' not in self._stubs: - self._stubs['delete_page'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Pages/DeletePage', - request_serializer=page.DeletePageRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_page'] - - 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"] - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - -__all__ = ( - 'PagesGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/transports/rest.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/transports/rest.py deleted file mode 100644 index e6120339..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/pages/transports/rest.py +++ /dev/null @@ -1,1228 +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.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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.dialogflowcx_v3.types import page -from google.cloud.dialogflowcx_v3.types import page as gcdc_page -from google.protobuf import empty_pb2 # type: ignore - -from .base import PagesTransport, 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 PagesRestInterceptor: - """Interceptor for Pages. - - 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 PagesRestTransport. - - .. code-block:: python - class MyCustomPagesInterceptor(PagesRestInterceptor): - def pre_create_page(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_page(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_page(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_get_page(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_page(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_pages(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_pages(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_page(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_page(self, response): - logging.log(f"Received response: {response}") - return response - - transport = PagesRestTransport(interceptor=MyCustomPagesInterceptor()) - client = PagesClient(transport=transport) - - - """ - def pre_create_page(self, request: gcdc_page.CreatePageRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_page.CreatePageRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_page - - Override in a subclass to manipulate the request or metadata - before they are sent to the Pages server. - """ - return request, metadata - - def post_create_page(self, response: gcdc_page.Page) -> gcdc_page.Page: - """Post-rpc interceptor for create_page - - Override in a subclass to manipulate the response - after it is returned by the Pages server but before - it is returned to user code. - """ - return response - def pre_delete_page(self, request: page.DeletePageRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[page.DeletePageRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_page - - Override in a subclass to manipulate the request or metadata - before they are sent to the Pages server. - """ - return request, metadata - - def pre_get_page(self, request: page.GetPageRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[page.GetPageRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_page - - Override in a subclass to manipulate the request or metadata - before they are sent to the Pages server. - """ - return request, metadata - - def post_get_page(self, response: page.Page) -> page.Page: - """Post-rpc interceptor for get_page - - Override in a subclass to manipulate the response - after it is returned by the Pages server but before - it is returned to user code. - """ - return response - def pre_list_pages(self, request: page.ListPagesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[page.ListPagesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_pages - - Override in a subclass to manipulate the request or metadata - before they are sent to the Pages server. - """ - return request, metadata - - def post_list_pages(self, response: page.ListPagesResponse) -> page.ListPagesResponse: - """Post-rpc interceptor for list_pages - - Override in a subclass to manipulate the response - after it is returned by the Pages server but before - it is returned to user code. - """ - return response - def pre_update_page(self, request: gcdc_page.UpdatePageRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_page.UpdatePageRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_page - - Override in a subclass to manipulate the request or metadata - before they are sent to the Pages server. - """ - return request, metadata - - def post_update_page(self, response: gcdc_page.Page) -> gcdc_page.Page: - """Post-rpc interceptor for update_page - - Override in a subclass to manipulate the response - after it is returned by the Pages server but before - it is returned to user code. - """ - return response - - def pre_get_location( - self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_location - - Override in a subclass to manipulate the request or metadata - before they are sent to the Pages server. - """ - return request, metadata - - def post_get_location( - self, response: locations_pb2.Location - ) -> locations_pb2.Location: - """Post-rpc interceptor for get_location - - Override in a subclass to manipulate the response - after it is returned by the Pages server but before - it is returned to user code. - """ - return response - def pre_list_locations( - self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_locations - - Override in a subclass to manipulate the request or metadata - before they are sent to the Pages server. - """ - return request, metadata - - def post_list_locations( - self, response: locations_pb2.ListLocationsResponse - ) -> locations_pb2.ListLocationsResponse: - """Post-rpc interceptor for list_locations - - Override in a subclass to manipulate the response - after it is returned by the Pages 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 Pages 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 Pages 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 Pages 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 Pages 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 Pages 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 Pages server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class PagesRestStub: - _session: AuthorizedSession - _host: str - _interceptor: PagesRestInterceptor - - -class PagesRestTransport(PagesTransport): - """REST backend transport for Pages. - - Service for managing [Pages][google.cloud.dialogflow.cx.v3.Page]. - - 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 = 'dialogflow.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[PagesRestInterceptor] = 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) - if client_cert_source_for_mtls: - self._session.configure_mtls_channel(client_cert_source_for_mtls) - self._interceptor = interceptor or PagesRestInterceptor() - self._prep_wrapped_messages(client_info) - - class _CreatePage(PagesRestStub): - def __hash__(self): - return hash("CreatePage") - - __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: gcdc_page.CreatePageRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_page.Page: - r"""Call the create page method over HTTP. - - Args: - request (~.gcdc_page.CreatePageRequest): - The request object. The request message for - [Pages.CreatePage][google.cloud.dialogflow.cx.v3.Pages.CreatePage]. - 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: - ~.gcdc_page.Page: - A Dialogflow CX conversation (session) can be described - and visualized as a state machine. The states of a CX - session are represented by pages. - - For each flow, you define many pages, where your - combined pages can handle a complete conversation on the - topics the flow is designed for. At any given moment, - exactly one page is the current page, the current page - is considered active, and the flow associated with that - page is considered active. Every flow has a special - start page. When a flow initially becomes active, the - start page page becomes the current page. For each - conversational turn, the current page will either stay - the same or transition to another page. - - You configure each page to collect information from the - end-user that is relevant for the conversational state - represented by the page. - - For more information, see the `Page - guide `__. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*/flows/*}/pages', - 'body': 'page', - }, - ] - request, metadata = self._interceptor.pre_create_page(request, metadata) - pb_request = gcdc_page.CreatePageRequest.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 = gcdc_page.Page() - pb_resp = gcdc_page.Page.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_page(resp) - return resp - - class _DeletePage(PagesRestStub): - def __hash__(self): - return hash("DeletePage") - - __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: page.DeletePageRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete page method over HTTP. - - Args: - request (~.page.DeletePageRequest): - The request object. The request message for - [Pages.DeletePage][google.cloud.dialogflow.cx.v3.Pages.DeletePage]. - 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': '/v3/{name=projects/*/locations/*/agents/*/flows/*/pages/*}', - }, - ] - request, metadata = self._interceptor.pre_delete_page(request, metadata) - pb_request = page.DeletePageRequest.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 _GetPage(PagesRestStub): - def __hash__(self): - return hash("GetPage") - - __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: page.GetPageRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> page.Page: - r"""Call the get page method over HTTP. - - Args: - request (~.page.GetPageRequest): - The request object. The request message for - [Pages.GetPage][google.cloud.dialogflow.cx.v3.Pages.GetPage]. - 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: - ~.page.Page: - A Dialogflow CX conversation (session) can be described - and visualized as a state machine. The states of a CX - session are represented by pages. - - For each flow, you define many pages, where your - combined pages can handle a complete conversation on the - topics the flow is designed for. At any given moment, - exactly one page is the current page, the current page - is considered active, and the flow associated with that - page is considered active. Every flow has a special - start page. When a flow initially becomes active, the - start page page becomes the current page. For each - conversational turn, the current page will either stay - the same or transition to another page. - - You configure each page to collect information from the - end-user that is relevant for the conversational state - represented by the page. - - For more information, see the `Page - guide `__. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/flows/*/pages/*}', - }, - ] - request, metadata = self._interceptor.pre_get_page(request, metadata) - pb_request = page.GetPageRequest.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 = page.Page() - pb_resp = page.Page.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_page(resp) - return resp - - class _ListPages(PagesRestStub): - def __hash__(self): - return hash("ListPages") - - __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: page.ListPagesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> page.ListPagesResponse: - r"""Call the list pages method over HTTP. - - Args: - request (~.page.ListPagesRequest): - The request object. The request message for - [Pages.ListPages][google.cloud.dialogflow.cx.v3.Pages.ListPages]. - 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: - ~.page.ListPagesResponse: - The response message for - [Pages.ListPages][google.cloud.dialogflow.cx.v3.Pages.ListPages]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*/flows/*}/pages', - }, - ] - request, metadata = self._interceptor.pre_list_pages(request, metadata) - pb_request = page.ListPagesRequest.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 = page.ListPagesResponse() - pb_resp = page.ListPagesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_pages(resp) - return resp - - class _UpdatePage(PagesRestStub): - def __hash__(self): - return hash("UpdatePage") - - __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: gcdc_page.UpdatePageRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_page.Page: - r"""Call the update page method over HTTP. - - Args: - request (~.gcdc_page.UpdatePageRequest): - The request object. The request message for - [Pages.UpdatePage][google.cloud.dialogflow.cx.v3.Pages.UpdatePage]. - 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: - ~.gcdc_page.Page: - A Dialogflow CX conversation (session) can be described - and visualized as a state machine. The states of a CX - session are represented by pages. - - For each flow, you define many pages, where your - combined pages can handle a complete conversation on the - topics the flow is designed for. At any given moment, - exactly one page is the current page, the current page - is considered active, and the flow associated with that - page is considered active. Every flow has a special - start page. When a flow initially becomes active, the - start page page becomes the current page. For each - conversational turn, the current page will either stay - the same or transition to another page. - - You configure each page to collect information from the - end-user that is relevant for the conversational state - represented by the page. - - For more information, see the `Page - guide `__. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v3/{page.name=projects/*/locations/*/agents/*/flows/*/pages/*}', - 'body': 'page', - }, - ] - request, metadata = self._interceptor.pre_update_page(request, metadata) - pb_request = gcdc_page.UpdatePageRequest.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 = gcdc_page.Page() - pb_resp = gcdc_page.Page.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_page(resp) - return resp - - @property - def create_page(self) -> Callable[ - [gcdc_page.CreatePageRequest], - gcdc_page.Page]: - # 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._CreatePage(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_page(self) -> Callable[ - [page.DeletePageRequest], - 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._DeletePage(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_page(self) -> Callable[ - [page.GetPageRequest], - page.Page]: - # 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._GetPage(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_pages(self) -> Callable[ - [page.ListPagesRequest], - page.ListPagesResponse]: - # 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._ListPages(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_page(self) -> Callable[ - [gcdc_page.UpdatePageRequest], - gcdc_page.Page]: - # 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._UpdatePage(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_location(self): - return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore - - class _GetLocation(PagesRestStub): - def __call__(self, - request: locations_pb2.GetLocationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.Location: - - r"""Call the get location method over HTTP. - - Args: - request (locations_pb2.GetLocationRequest): - The request object for GetLocation 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: - locations_pb2.Location: Response from GetLocation method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*}', - }, - ] - - request, metadata = self._interceptor.pre_get_location(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 = locations_pb2.Location() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_get_location(resp) - return resp - - @property - def list_locations(self): - return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore - - class _ListLocations(PagesRestStub): - def __call__(self, - request: locations_pb2.ListLocationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.ListLocationsResponse: - - r"""Call the list locations method over HTTP. - - Args: - request (locations_pb2.ListLocationsRequest): - The request object for ListLocations 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: - locations_pb2.ListLocationsResponse: Response from ListLocations method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*}/locations', - }, - ] - - request, metadata = self._interceptor.pre_list_locations(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 = locations_pb2.ListLocationsResponse() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_list_locations(resp) - return resp - - @property - def cancel_operation(self): - return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore - - class _CancelOperation(PagesRestStub): - 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': '/v3/{name=projects/*/operations/*}:cancel', - }, -{ - 'method': 'post', - 'uri': '/v3/{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(PagesRestStub): - 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': '/v3/{name=projects/*/operations/*}', - }, -{ - 'method': 'get', - 'uri': '/v3/{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(PagesRestStub): - 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': '/v3/{name=projects/*}/operations', - }, -{ - 'method': 'get', - 'uri': '/v3/{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__=( - 'PagesRestTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/__init__.py deleted file mode 100644 index 2c9112a8..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/__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 SecuritySettingsServiceClient -from .async_client import SecuritySettingsServiceAsyncClient - -__all__ = ( - 'SecuritySettingsServiceClient', - 'SecuritySettingsServiceAsyncClient', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/async_client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/async_client.py deleted file mode 100644 index df177c16..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/async_client.py +++ /dev/null @@ -1,1018 +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.dialogflowcx_v3 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.cloud.dialogflowcx_v3.services.security_settings_service import pagers -from google.cloud.dialogflowcx_v3.types import security_settings -from google.cloud.dialogflowcx_v3.types import security_settings as gcdc_security_settings -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import SecuritySettingsServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import SecuritySettingsServiceGrpcAsyncIOTransport -from .client import SecuritySettingsServiceClient - - -class SecuritySettingsServiceAsyncClient: - """Service for managing security settings for Dialogflow.""" - - _client: SecuritySettingsServiceClient - - DEFAULT_ENDPOINT = SecuritySettingsServiceClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = SecuritySettingsServiceClient.DEFAULT_MTLS_ENDPOINT - - deidentify_template_path = staticmethod(SecuritySettingsServiceClient.deidentify_template_path) - parse_deidentify_template_path = staticmethod(SecuritySettingsServiceClient.parse_deidentify_template_path) - inspect_template_path = staticmethod(SecuritySettingsServiceClient.inspect_template_path) - parse_inspect_template_path = staticmethod(SecuritySettingsServiceClient.parse_inspect_template_path) - security_settings_path = staticmethod(SecuritySettingsServiceClient.security_settings_path) - parse_security_settings_path = staticmethod(SecuritySettingsServiceClient.parse_security_settings_path) - common_billing_account_path = staticmethod(SecuritySettingsServiceClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(SecuritySettingsServiceClient.parse_common_billing_account_path) - common_folder_path = staticmethod(SecuritySettingsServiceClient.common_folder_path) - parse_common_folder_path = staticmethod(SecuritySettingsServiceClient.parse_common_folder_path) - common_organization_path = staticmethod(SecuritySettingsServiceClient.common_organization_path) - parse_common_organization_path = staticmethod(SecuritySettingsServiceClient.parse_common_organization_path) - common_project_path = staticmethod(SecuritySettingsServiceClient.common_project_path) - parse_common_project_path = staticmethod(SecuritySettingsServiceClient.parse_common_project_path) - common_location_path = staticmethod(SecuritySettingsServiceClient.common_location_path) - parse_common_location_path = staticmethod(SecuritySettingsServiceClient.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: - SecuritySettingsServiceAsyncClient: The constructed client. - """ - return SecuritySettingsServiceClient.from_service_account_info.__func__(SecuritySettingsServiceAsyncClient, 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: - SecuritySettingsServiceAsyncClient: The constructed client. - """ - return SecuritySettingsServiceClient.from_service_account_file.__func__(SecuritySettingsServiceAsyncClient, 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 SecuritySettingsServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> SecuritySettingsServiceTransport: - """Returns the transport used by the client instance. - - Returns: - SecuritySettingsServiceTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(SecuritySettingsServiceClient).get_transport_class, type(SecuritySettingsServiceClient)) - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, SecuritySettingsServiceTransport] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the security settings service 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, ~.SecuritySettingsServiceTransport]): 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 = SecuritySettingsServiceClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def create_security_settings(self, - request: Optional[Union[gcdc_security_settings.CreateSecuritySettingsRequest, dict]] = None, - *, - parent: Optional[str] = None, - security_settings: Optional[gcdc_security_settings.SecuritySettings] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_security_settings.SecuritySettings: - r"""Create security settings in the specified location. - - .. 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 dialogflowcx_v3 - - async def sample_create_security_settings(): - # Create a client - client = dialogflowcx_v3.SecuritySettingsServiceAsyncClient() - - # Initialize request argument(s) - security_settings = dialogflowcx_v3.SecuritySettings() - security_settings.retention_window_days = 2271 - security_settings.display_name = "display_name_value" - - request = dialogflowcx_v3.CreateSecuritySettingsRequest( - parent="parent_value", - security_settings=security_settings, - ) - - # Make the request - response = await client.create_security_settings(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.CreateSecuritySettingsRequest, dict]]): - The request object. The request message for - [SecuritySettings.CreateSecuritySettings][]. - parent (:class:`str`): - Required. The location to create an - [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings] - for. Format: - ``projects//locations/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - security_settings (:class:`google.cloud.dialogflowcx_v3.types.SecuritySettings`): - Required. The security settings to - create. - - This corresponds to the ``security_settings`` 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.dialogflowcx_v3.types.SecuritySettings: - Represents the settings related to - security issues, such as data redaction - and data retention. It may take hours - for updates on the settings to propagate - to all the related components and take - effect. - - """ - # 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, security_settings]) - 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 = gcdc_security_settings.CreateSecuritySettingsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if security_settings is not None: - request.security_settings = security_settings - - # 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_security_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(( - ("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_security_settings(self, - request: Optional[Union[security_settings.GetSecuritySettingsRequest, 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]] = (), - ) -> security_settings.SecuritySettings: - r"""Retrieves the specified - [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. - The returned settings may be stale by up to 1 minute. - - .. 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 dialogflowcx_v3 - - async def sample_get_security_settings(): - # Create a client - client = dialogflowcx_v3.SecuritySettingsServiceAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetSecuritySettingsRequest( - name="name_value", - ) - - # Make the request - response = await client.get_security_settings(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.GetSecuritySettingsRequest, dict]]): - The request object. The request message for - [SecuritySettingsService.GetSecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettingsService.GetSecuritySettings]. - name (:class:`str`): - Required. Resource name of the settings. Format: - ``projects//locations//securitySettings/``. - - 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.dialogflowcx_v3.types.SecuritySettings: - Represents the settings related to - security issues, such as data redaction - and data retention. It may take hours - for updates on the settings to propagate - to all the related components and take - effect. - - """ - # 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 = security_settings.GetSecuritySettingsRequest(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_security_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_security_settings(self, - request: Optional[Union[gcdc_security_settings.UpdateSecuritySettingsRequest, dict]] = None, - *, - security_settings: Optional[gcdc_security_settings.SecuritySettings] = 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]] = (), - ) -> gcdc_security_settings.SecuritySettings: - r"""Updates the specified - [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. - - .. 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 dialogflowcx_v3 - - async def sample_update_security_settings(): - # Create a client - client = dialogflowcx_v3.SecuritySettingsServiceAsyncClient() - - # Initialize request argument(s) - security_settings = dialogflowcx_v3.SecuritySettings() - security_settings.retention_window_days = 2271 - security_settings.display_name = "display_name_value" - - request = dialogflowcx_v3.UpdateSecuritySettingsRequest( - security_settings=security_settings, - ) - - # Make the request - response = await client.update_security_settings(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.UpdateSecuritySettingsRequest, dict]]): - The request object. The request message for - [SecuritySettingsService.UpdateSecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettingsService.UpdateSecuritySettings]. - security_settings (:class:`google.cloud.dialogflowcx_v3.types.SecuritySettings`): - Required. [SecuritySettings] object that contains values - for each of the fields to update. - - This corresponds to the ``security_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 mask to control which - fields get updated. If the mask is not - present, all fields will 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.dialogflowcx_v3.types.SecuritySettings: - Represents the settings related to - security issues, such as data redaction - and data retention. It may take hours - for updates on the settings to propagate - to all the related components and take - effect. - - """ - # 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([security_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 = gcdc_security_settings.UpdateSecuritySettingsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if security_settings is not None: - request.security_settings = security_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_security_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(( - ("security_settings.name", request.security_settings.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_security_settings(self, - request: Optional[Union[security_settings.ListSecuritySettingsRequest, 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.ListSecuritySettingsAsyncPager: - r"""Returns the list of all security settings in the - specified location. - - .. 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 dialogflowcx_v3 - - async def sample_list_security_settings(): - # Create a client - client = dialogflowcx_v3.SecuritySettingsServiceAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListSecuritySettingsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_security_settings(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ListSecuritySettingsRequest, dict]]): - The request object. The request message for - [SecuritySettings.ListSecuritySettings][]. - parent (:class:`str`): - Required. The location to list all security settings - for. Format: - ``projects//locations/``. - - 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.dialogflowcx_v3.services.security_settings_service.pagers.ListSecuritySettingsAsyncPager: - The response message for - [SecuritySettings.ListSecuritySettings][]. - - 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 = security_settings.ListSecuritySettingsRequest(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_security_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(( - ("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.ListSecuritySettingsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_security_settings(self, - request: Optional[Union[security_settings.DeleteSecuritySettingsRequest, 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 the specified - [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. - - .. 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 dialogflowcx_v3 - - async def sample_delete_security_settings(): - # Create a client - client = dialogflowcx_v3.SecuritySettingsServiceAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteSecuritySettingsRequest( - name="name_value", - ) - - # Make the request - await client.delete_security_settings(request=request) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.DeleteSecuritySettingsRequest, dict]]): - The request object. The request message for - [SecuritySettings.DeleteSecuritySettings][]. - name (:class:`str`): - Required. The name of the - [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings] - to delete. Format: - ``projects//locations//securitySettings/``. - - 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 = security_settings.DeleteSecuritySettingsRequest(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_security_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. - 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 get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**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_location, - 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_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**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_locations, - 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 __aenter__(self) -> "SecuritySettingsServiceAsyncClient": - 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__ = ( - "SecuritySettingsServiceAsyncClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/client.py deleted file mode 100644 index c3c8ff23..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/client.py +++ /dev/null @@ -1,1235 +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.dialogflowcx_v3 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.cloud.dialogflowcx_v3.services.security_settings_service import pagers -from google.cloud.dialogflowcx_v3.types import security_settings -from google.cloud.dialogflowcx_v3.types import security_settings as gcdc_security_settings -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import SecuritySettingsServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import SecuritySettingsServiceGrpcTransport -from .transports.grpc_asyncio import SecuritySettingsServiceGrpcAsyncIOTransport -from .transports.rest import SecuritySettingsServiceRestTransport - - -class SecuritySettingsServiceClientMeta(type): - """Metaclass for the SecuritySettingsService 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[SecuritySettingsServiceTransport]] - _transport_registry["grpc"] = SecuritySettingsServiceGrpcTransport - _transport_registry["grpc_asyncio"] = SecuritySettingsServiceGrpcAsyncIOTransport - _transport_registry["rest"] = SecuritySettingsServiceRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[SecuritySettingsServiceTransport]: - """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 SecuritySettingsServiceClient(metaclass=SecuritySettingsServiceClientMeta): - """Service for managing security settings for Dialogflow.""" - - @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 = "dialogflow.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: - SecuritySettingsServiceClient: 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: - SecuritySettingsServiceClient: 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) -> SecuritySettingsServiceTransport: - """Returns the transport used by the client instance. - - Returns: - SecuritySettingsServiceTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def deidentify_template_path(organization: str,location: str,deidentify_template: str,) -> str: - """Returns a fully-qualified deidentify_template string.""" - return "organizations/{organization}/locations/{location}/deidentifyTemplates/{deidentify_template}".format(organization=organization, location=location, deidentify_template=deidentify_template, ) - - @staticmethod - def parse_deidentify_template_path(path: str) -> Dict[str,str]: - """Parses a deidentify_template path into its component segments.""" - m = re.match(r"^organizations/(?P.+?)/locations/(?P.+?)/deidentifyTemplates/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def inspect_template_path(organization: str,location: str,inspect_template: str,) -> str: - """Returns a fully-qualified inspect_template string.""" - return "organizations/{organization}/locations/{location}/inspectTemplates/{inspect_template}".format(organization=organization, location=location, inspect_template=inspect_template, ) - - @staticmethod - def parse_inspect_template_path(path: str) -> Dict[str,str]: - """Parses a inspect_template path into its component segments.""" - m = re.match(r"^organizations/(?P.+?)/locations/(?P.+?)/inspectTemplates/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def security_settings_path(project: str,location: str,security_settings: str,) -> str: - """Returns a fully-qualified security_settings string.""" - return "projects/{project}/locations/{location}/securitySettings/{security_settings}".format(project=project, location=location, security_settings=security_settings, ) - - @staticmethod - def parse_security_settings_path(path: str) -> Dict[str,str]: - """Parses a security_settings path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/securitySettings/(?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, SecuritySettingsServiceTransport]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the security settings service 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, SecuritySettingsServiceTransport]): 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, SecuritySettingsServiceTransport): - # transport is a SecuritySettingsServiceTransport 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_security_settings(self, - request: Optional[Union[gcdc_security_settings.CreateSecuritySettingsRequest, dict]] = None, - *, - parent: Optional[str] = None, - security_settings: Optional[gcdc_security_settings.SecuritySettings] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_security_settings.SecuritySettings: - r"""Create security settings in the specified location. - - .. 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 dialogflowcx_v3 - - def sample_create_security_settings(): - # Create a client - client = dialogflowcx_v3.SecuritySettingsServiceClient() - - # Initialize request argument(s) - security_settings = dialogflowcx_v3.SecuritySettings() - security_settings.retention_window_days = 2271 - security_settings.display_name = "display_name_value" - - request = dialogflowcx_v3.CreateSecuritySettingsRequest( - parent="parent_value", - security_settings=security_settings, - ) - - # Make the request - response = client.create_security_settings(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.CreateSecuritySettingsRequest, dict]): - The request object. The request message for - [SecuritySettings.CreateSecuritySettings][]. - parent (str): - Required. The location to create an - [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings] - for. Format: - ``projects//locations/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - security_settings (google.cloud.dialogflowcx_v3.types.SecuritySettings): - Required. The security settings to - create. - - This corresponds to the ``security_settings`` 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.dialogflowcx_v3.types.SecuritySettings: - Represents the settings related to - security issues, such as data redaction - and data retention. It may take hours - for updates on the settings to propagate - to all the related components and take - effect. - - """ - # 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, security_settings]) - 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 gcdc_security_settings.CreateSecuritySettingsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_security_settings.CreateSecuritySettingsRequest): - request = gcdc_security_settings.CreateSecuritySettingsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if security_settings is not None: - request.security_settings = security_settings - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_security_settings] - - # 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_security_settings(self, - request: Optional[Union[security_settings.GetSecuritySettingsRequest, 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]] = (), - ) -> security_settings.SecuritySettings: - r"""Retrieves the specified - [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. - The returned settings may be stale by up to 1 minute. - - .. 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 dialogflowcx_v3 - - def sample_get_security_settings(): - # Create a client - client = dialogflowcx_v3.SecuritySettingsServiceClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetSecuritySettingsRequest( - name="name_value", - ) - - # Make the request - response = client.get_security_settings(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.GetSecuritySettingsRequest, dict]): - The request object. The request message for - [SecuritySettingsService.GetSecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettingsService.GetSecuritySettings]. - name (str): - Required. Resource name of the settings. Format: - ``projects//locations//securitySettings/``. - - 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.dialogflowcx_v3.types.SecuritySettings: - Represents the settings related to - security issues, such as data redaction - and data retention. It may take hours - for updates on the settings to propagate - to all the related components and take - effect. - - """ - # 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 security_settings.GetSecuritySettingsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, security_settings.GetSecuritySettingsRequest): - request = security_settings.GetSecuritySettingsRequest(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_security_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_security_settings(self, - request: Optional[Union[gcdc_security_settings.UpdateSecuritySettingsRequest, dict]] = None, - *, - security_settings: Optional[gcdc_security_settings.SecuritySettings] = 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]] = (), - ) -> gcdc_security_settings.SecuritySettings: - r"""Updates the specified - [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. - - .. 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 dialogflowcx_v3 - - def sample_update_security_settings(): - # Create a client - client = dialogflowcx_v3.SecuritySettingsServiceClient() - - # Initialize request argument(s) - security_settings = dialogflowcx_v3.SecuritySettings() - security_settings.retention_window_days = 2271 - security_settings.display_name = "display_name_value" - - request = dialogflowcx_v3.UpdateSecuritySettingsRequest( - security_settings=security_settings, - ) - - # Make the request - response = client.update_security_settings(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.UpdateSecuritySettingsRequest, dict]): - The request object. The request message for - [SecuritySettingsService.UpdateSecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettingsService.UpdateSecuritySettings]. - security_settings (google.cloud.dialogflowcx_v3.types.SecuritySettings): - Required. [SecuritySettings] object that contains values - for each of the fields to update. - - This corresponds to the ``security_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 mask to control which - fields get updated. If the mask is not - present, all fields will 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.dialogflowcx_v3.types.SecuritySettings: - Represents the settings related to - security issues, such as data redaction - and data retention. It may take hours - for updates on the settings to propagate - to all the related components and take - effect. - - """ - # 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([security_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 gcdc_security_settings.UpdateSecuritySettingsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_security_settings.UpdateSecuritySettingsRequest): - request = gcdc_security_settings.UpdateSecuritySettingsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if security_settings is not None: - request.security_settings = security_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_security_settings] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("security_settings.name", request.security_settings.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_security_settings(self, - request: Optional[Union[security_settings.ListSecuritySettingsRequest, 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.ListSecuritySettingsPager: - r"""Returns the list of all security settings in the - specified location. - - .. 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 dialogflowcx_v3 - - def sample_list_security_settings(): - # Create a client - client = dialogflowcx_v3.SecuritySettingsServiceClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListSecuritySettingsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_security_settings(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ListSecuritySettingsRequest, dict]): - The request object. The request message for - [SecuritySettings.ListSecuritySettings][]. - parent (str): - Required. The location to list all security settings - for. Format: - ``projects//locations/``. - - 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.dialogflowcx_v3.services.security_settings_service.pagers.ListSecuritySettingsPager: - The response message for - [SecuritySettings.ListSecuritySettings][]. - - 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 security_settings.ListSecuritySettingsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, security_settings.ListSecuritySettingsRequest): - request = security_settings.ListSecuritySettingsRequest(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_security_settings] - - # 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.ListSecuritySettingsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_security_settings(self, - request: Optional[Union[security_settings.DeleteSecuritySettingsRequest, 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 the specified - [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. - - .. 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 dialogflowcx_v3 - - def sample_delete_security_settings(): - # Create a client - client = dialogflowcx_v3.SecuritySettingsServiceClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteSecuritySettingsRequest( - name="name_value", - ) - - # Make the request - client.delete_security_settings(request=request) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.DeleteSecuritySettingsRequest, dict]): - The request object. The request message for - [SecuritySettings.DeleteSecuritySettings][]. - name (str): - Required. The name of the - [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings] - to delete. Format: - ``projects//locations//securitySettings/``. - - 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 security_settings.DeleteSecuritySettingsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, security_settings.DeleteSecuritySettingsRequest): - request = security_settings.DeleteSecuritySettingsRequest(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_security_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. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def __enter__(self) -> "SecuritySettingsServiceClient": - 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,) - - def get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.get_location, - 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 list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.list_locations, - 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 - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "SecuritySettingsServiceClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/pagers.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/pagers.py deleted file mode 100644 index 712c14a4..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/pagers.py +++ /dev/null @@ -1,139 +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.dialogflowcx_v3.types import security_settings - - -class ListSecuritySettingsPager: - """A pager for iterating through ``list_security_settings`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListSecuritySettingsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``security_settings`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListSecuritySettings`` requests and continue to iterate - through the ``security_settings`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListSecuritySettingsResponse` - 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[..., security_settings.ListSecuritySettingsResponse], - request: security_settings.ListSecuritySettingsRequest, - response: security_settings.ListSecuritySettingsResponse, - *, - 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.dialogflowcx_v3.types.ListSecuritySettingsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListSecuritySettingsResponse): - 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 = security_settings.ListSecuritySettingsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[security_settings.ListSecuritySettingsResponse]: - 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[security_settings.SecuritySettings]: - for page in self.pages: - yield from page.security_settings - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListSecuritySettingsAsyncPager: - """A pager for iterating through ``list_security_settings`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListSecuritySettingsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``security_settings`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListSecuritySettings`` requests and continue to iterate - through the ``security_settings`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListSecuritySettingsResponse` - 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[security_settings.ListSecuritySettingsResponse]], - request: security_settings.ListSecuritySettingsRequest, - response: security_settings.ListSecuritySettingsResponse, - *, - 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.dialogflowcx_v3.types.ListSecuritySettingsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListSecuritySettingsResponse): - 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 = security_settings.ListSecuritySettingsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[security_settings.ListSecuritySettingsResponse]: - 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[security_settings.SecuritySettings]: - async def async_generator(): - async for page in self.pages: - for response in page.security_settings: - 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/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/__init__.py deleted file mode 100644 index 06f85b2d..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/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 SecuritySettingsServiceTransport -from .grpc import SecuritySettingsServiceGrpcTransport -from .grpc_asyncio import SecuritySettingsServiceGrpcAsyncIOTransport -from .rest import SecuritySettingsServiceRestTransport -from .rest import SecuritySettingsServiceRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[SecuritySettingsServiceTransport]] -_transport_registry['grpc'] = SecuritySettingsServiceGrpcTransport -_transport_registry['grpc_asyncio'] = SecuritySettingsServiceGrpcAsyncIOTransport -_transport_registry['rest'] = SecuritySettingsServiceRestTransport - -__all__ = ( - 'SecuritySettingsServiceTransport', - 'SecuritySettingsServiceGrpcTransport', - 'SecuritySettingsServiceGrpcAsyncIOTransport', - 'SecuritySettingsServiceRestTransport', - 'SecuritySettingsServiceRestInterceptor', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/base.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/base.py deleted file mode 100644 index 6d82b092..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/base.py +++ /dev/null @@ -1,252 +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.dialogflowcx_v3 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.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.dialogflowcx_v3.types import security_settings -from google.cloud.dialogflowcx_v3.types import security_settings as gcdc_security_settings -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -class SecuritySettingsServiceTransport(abc.ABC): - """Abstract transport class for SecuritySettingsService.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/dialogflow', - ) - - DEFAULT_HOST: str = 'dialogflow.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_security_settings: gapic_v1.method.wrap_method( - self.create_security_settings, - default_timeout=None, - client_info=client_info, - ), - self.get_security_settings: gapic_v1.method.wrap_method( - self.get_security_settings, - default_timeout=None, - client_info=client_info, - ), - self.update_security_settings: gapic_v1.method.wrap_method( - self.update_security_settings, - default_timeout=None, - client_info=client_info, - ), - self.list_security_settings: gapic_v1.method.wrap_method( - self.list_security_settings, - default_timeout=None, - client_info=client_info, - ), - self.delete_security_settings: gapic_v1.method.wrap_method( - self.delete_security_settings, - 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 create_security_settings(self) -> Callable[ - [gcdc_security_settings.CreateSecuritySettingsRequest], - Union[ - gcdc_security_settings.SecuritySettings, - Awaitable[gcdc_security_settings.SecuritySettings] - ]]: - raise NotImplementedError() - - @property - def get_security_settings(self) -> Callable[ - [security_settings.GetSecuritySettingsRequest], - Union[ - security_settings.SecuritySettings, - Awaitable[security_settings.SecuritySettings] - ]]: - raise NotImplementedError() - - @property - def update_security_settings(self) -> Callable[ - [gcdc_security_settings.UpdateSecuritySettingsRequest], - Union[ - gcdc_security_settings.SecuritySettings, - Awaitable[gcdc_security_settings.SecuritySettings] - ]]: - raise NotImplementedError() - - @property - def list_security_settings(self) -> Callable[ - [security_settings.ListSecuritySettingsRequest], - Union[ - security_settings.ListSecuritySettingsResponse, - Awaitable[security_settings.ListSecuritySettingsResponse] - ]]: - raise NotImplementedError() - - @property - def delete_security_settings(self) -> Callable[ - [security_settings.DeleteSecuritySettingsRequest], - 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 get_location(self, - ) -> Callable[ - [locations_pb2.GetLocationRequest], - Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], - ]: - raise NotImplementedError() - - @property - def list_locations(self, - ) -> Callable[ - [locations_pb2.ListLocationsRequest], - Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'SecuritySettingsServiceTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/grpc.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/grpc.py deleted file mode 100644 index b1f3f59d..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/grpc.py +++ /dev/null @@ -1,467 +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 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.dialogflowcx_v3.types import security_settings -from google.cloud.dialogflowcx_v3.types import security_settings as gcdc_security_settings -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from .base import SecuritySettingsServiceTransport, DEFAULT_CLIENT_INFO - - -class SecuritySettingsServiceGrpcTransport(SecuritySettingsServiceTransport): - """gRPC backend transport for SecuritySettingsService. - - Service for managing security settings for Dialogflow. - - 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 = 'dialogflow.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] = {} - - 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 = 'dialogflow.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 create_security_settings(self) -> Callable[ - [gcdc_security_settings.CreateSecuritySettingsRequest], - gcdc_security_settings.SecuritySettings]: - r"""Return a callable for the create security settings method over gRPC. - - Create security settings in the specified location. - - Returns: - Callable[[~.CreateSecuritySettingsRequest], - ~.SecuritySettings]: - 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_security_settings' not in self._stubs: - self._stubs['create_security_settings'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.SecuritySettingsService/CreateSecuritySettings', - request_serializer=gcdc_security_settings.CreateSecuritySettingsRequest.serialize, - response_deserializer=gcdc_security_settings.SecuritySettings.deserialize, - ) - return self._stubs['create_security_settings'] - - @property - def get_security_settings(self) -> Callable[ - [security_settings.GetSecuritySettingsRequest], - security_settings.SecuritySettings]: - r"""Return a callable for the get security settings method over gRPC. - - Retrieves the specified - [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. - The returned settings may be stale by up to 1 minute. - - Returns: - Callable[[~.GetSecuritySettingsRequest], - ~.SecuritySettings]: - 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_security_settings' not in self._stubs: - self._stubs['get_security_settings'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.SecuritySettingsService/GetSecuritySettings', - request_serializer=security_settings.GetSecuritySettingsRequest.serialize, - response_deserializer=security_settings.SecuritySettings.deserialize, - ) - return self._stubs['get_security_settings'] - - @property - def update_security_settings(self) -> Callable[ - [gcdc_security_settings.UpdateSecuritySettingsRequest], - gcdc_security_settings.SecuritySettings]: - r"""Return a callable for the update security settings method over gRPC. - - Updates the specified - [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. - - Returns: - Callable[[~.UpdateSecuritySettingsRequest], - ~.SecuritySettings]: - 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_security_settings' not in self._stubs: - self._stubs['update_security_settings'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.SecuritySettingsService/UpdateSecuritySettings', - request_serializer=gcdc_security_settings.UpdateSecuritySettingsRequest.serialize, - response_deserializer=gcdc_security_settings.SecuritySettings.deserialize, - ) - return self._stubs['update_security_settings'] - - @property - def list_security_settings(self) -> Callable[ - [security_settings.ListSecuritySettingsRequest], - security_settings.ListSecuritySettingsResponse]: - r"""Return a callable for the list security settings method over gRPC. - - Returns the list of all security settings in the - specified location. - - Returns: - Callable[[~.ListSecuritySettingsRequest], - ~.ListSecuritySettingsResponse]: - 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_security_settings' not in self._stubs: - self._stubs['list_security_settings'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.SecuritySettingsService/ListSecuritySettings', - request_serializer=security_settings.ListSecuritySettingsRequest.serialize, - response_deserializer=security_settings.ListSecuritySettingsResponse.deserialize, - ) - return self._stubs['list_security_settings'] - - @property - def delete_security_settings(self) -> Callable[ - [security_settings.DeleteSecuritySettingsRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete security settings method over gRPC. - - Deletes the specified - [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. - - Returns: - Callable[[~.DeleteSecuritySettingsRequest], - ~.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_security_settings' not in self._stubs: - self._stubs['delete_security_settings'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.SecuritySettingsService/DeleteSecuritySettings', - request_serializer=security_settings.DeleteSecuritySettingsRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_security_settings'] - - 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 list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'SecuritySettingsServiceGrpcTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/grpc_asyncio.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/grpc_asyncio.py deleted file mode 100644 index bd1fd980..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/grpc_asyncio.py +++ /dev/null @@ -1,466 +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.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.dialogflowcx_v3.types import security_settings -from google.cloud.dialogflowcx_v3.types import security_settings as gcdc_security_settings -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from .base import SecuritySettingsServiceTransport, DEFAULT_CLIENT_INFO -from .grpc import SecuritySettingsServiceGrpcTransport - - -class SecuritySettingsServiceGrpcAsyncIOTransport(SecuritySettingsServiceTransport): - """gRPC AsyncIO backend transport for SecuritySettingsService. - - Service for managing security settings for Dialogflow. - - 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 = 'dialogflow.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 = 'dialogflow.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] = {} - - 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 create_security_settings(self) -> Callable[ - [gcdc_security_settings.CreateSecuritySettingsRequest], - Awaitable[gcdc_security_settings.SecuritySettings]]: - r"""Return a callable for the create security settings method over gRPC. - - Create security settings in the specified location. - - Returns: - Callable[[~.CreateSecuritySettingsRequest], - Awaitable[~.SecuritySettings]]: - 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_security_settings' not in self._stubs: - self._stubs['create_security_settings'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.SecuritySettingsService/CreateSecuritySettings', - request_serializer=gcdc_security_settings.CreateSecuritySettingsRequest.serialize, - response_deserializer=gcdc_security_settings.SecuritySettings.deserialize, - ) - return self._stubs['create_security_settings'] - - @property - def get_security_settings(self) -> Callable[ - [security_settings.GetSecuritySettingsRequest], - Awaitable[security_settings.SecuritySettings]]: - r"""Return a callable for the get security settings method over gRPC. - - Retrieves the specified - [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. - The returned settings may be stale by up to 1 minute. - - Returns: - Callable[[~.GetSecuritySettingsRequest], - Awaitable[~.SecuritySettings]]: - 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_security_settings' not in self._stubs: - self._stubs['get_security_settings'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.SecuritySettingsService/GetSecuritySettings', - request_serializer=security_settings.GetSecuritySettingsRequest.serialize, - response_deserializer=security_settings.SecuritySettings.deserialize, - ) - return self._stubs['get_security_settings'] - - @property - def update_security_settings(self) -> Callable[ - [gcdc_security_settings.UpdateSecuritySettingsRequest], - Awaitable[gcdc_security_settings.SecuritySettings]]: - r"""Return a callable for the update security settings method over gRPC. - - Updates the specified - [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. - - Returns: - Callable[[~.UpdateSecuritySettingsRequest], - Awaitable[~.SecuritySettings]]: - 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_security_settings' not in self._stubs: - self._stubs['update_security_settings'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.SecuritySettingsService/UpdateSecuritySettings', - request_serializer=gcdc_security_settings.UpdateSecuritySettingsRequest.serialize, - response_deserializer=gcdc_security_settings.SecuritySettings.deserialize, - ) - return self._stubs['update_security_settings'] - - @property - def list_security_settings(self) -> Callable[ - [security_settings.ListSecuritySettingsRequest], - Awaitable[security_settings.ListSecuritySettingsResponse]]: - r"""Return a callable for the list security settings method over gRPC. - - Returns the list of all security settings in the - specified location. - - Returns: - Callable[[~.ListSecuritySettingsRequest], - Awaitable[~.ListSecuritySettingsResponse]]: - 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_security_settings' not in self._stubs: - self._stubs['list_security_settings'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.SecuritySettingsService/ListSecuritySettings', - request_serializer=security_settings.ListSecuritySettingsRequest.serialize, - response_deserializer=security_settings.ListSecuritySettingsResponse.deserialize, - ) - return self._stubs['list_security_settings'] - - @property - def delete_security_settings(self) -> Callable[ - [security_settings.DeleteSecuritySettingsRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete security settings method over gRPC. - - Deletes the specified - [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. - - Returns: - Callable[[~.DeleteSecuritySettingsRequest], - 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_security_settings' not in self._stubs: - self._stubs['delete_security_settings'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.SecuritySettingsService/DeleteSecuritySettings', - request_serializer=security_settings.DeleteSecuritySettingsRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_security_settings'] - - 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"] - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - -__all__ = ( - 'SecuritySettingsServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/rest.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/rest.py deleted file mode 100644 index 5ff3ff4b..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/rest.py +++ /dev/null @@ -1,1183 +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.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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.dialogflowcx_v3.types import security_settings -from google.cloud.dialogflowcx_v3.types import security_settings as gcdc_security_settings -from google.protobuf import empty_pb2 # type: ignore - -from .base import SecuritySettingsServiceTransport, 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 SecuritySettingsServiceRestInterceptor: - """Interceptor for SecuritySettingsService. - - 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 SecuritySettingsServiceRestTransport. - - .. code-block:: python - class MyCustomSecuritySettingsServiceInterceptor(SecuritySettingsServiceRestInterceptor): - def pre_create_security_settings(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_security_settings(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_security_settings(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_get_security_settings(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_security_settings(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_security_settings(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_security_settings(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_security_settings(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_security_settings(self, response): - logging.log(f"Received response: {response}") - return response - - transport = SecuritySettingsServiceRestTransport(interceptor=MyCustomSecuritySettingsServiceInterceptor()) - client = SecuritySettingsServiceClient(transport=transport) - - - """ - def pre_create_security_settings(self, request: gcdc_security_settings.CreateSecuritySettingsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_security_settings.CreateSecuritySettingsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_security_settings - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecuritySettingsService server. - """ - return request, metadata - - def post_create_security_settings(self, response: gcdc_security_settings.SecuritySettings) -> gcdc_security_settings.SecuritySettings: - """Post-rpc interceptor for create_security_settings - - Override in a subclass to manipulate the response - after it is returned by the SecuritySettingsService server but before - it is returned to user code. - """ - return response - def pre_delete_security_settings(self, request: security_settings.DeleteSecuritySettingsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_settings.DeleteSecuritySettingsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_security_settings - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecuritySettingsService server. - """ - return request, metadata - - def pre_get_security_settings(self, request: security_settings.GetSecuritySettingsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_settings.GetSecuritySettingsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_security_settings - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecuritySettingsService server. - """ - return request, metadata - - def post_get_security_settings(self, response: security_settings.SecuritySettings) -> security_settings.SecuritySettings: - """Post-rpc interceptor for get_security_settings - - Override in a subclass to manipulate the response - after it is returned by the SecuritySettingsService server but before - it is returned to user code. - """ - return response - def pre_list_security_settings(self, request: security_settings.ListSecuritySettingsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_settings.ListSecuritySettingsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_security_settings - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecuritySettingsService server. - """ - return request, metadata - - def post_list_security_settings(self, response: security_settings.ListSecuritySettingsResponse) -> security_settings.ListSecuritySettingsResponse: - """Post-rpc interceptor for list_security_settings - - Override in a subclass to manipulate the response - after it is returned by the SecuritySettingsService server but before - it is returned to user code. - """ - return response - def pre_update_security_settings(self, request: gcdc_security_settings.UpdateSecuritySettingsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_security_settings.UpdateSecuritySettingsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_security_settings - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecuritySettingsService server. - """ - return request, metadata - - def post_update_security_settings(self, response: gcdc_security_settings.SecuritySettings) -> gcdc_security_settings.SecuritySettings: - """Post-rpc interceptor for update_security_settings - - Override in a subclass to manipulate the response - after it is returned by the SecuritySettingsService server but before - it is returned to user code. - """ - return response - - def pre_get_location( - self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_location - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecuritySettingsService server. - """ - return request, metadata - - def post_get_location( - self, response: locations_pb2.Location - ) -> locations_pb2.Location: - """Post-rpc interceptor for get_location - - Override in a subclass to manipulate the response - after it is returned by the SecuritySettingsService server but before - it is returned to user code. - """ - return response - def pre_list_locations( - self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_locations - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecuritySettingsService server. - """ - return request, metadata - - def post_list_locations( - self, response: locations_pb2.ListLocationsResponse - ) -> locations_pb2.ListLocationsResponse: - """Post-rpc interceptor for list_locations - - Override in a subclass to manipulate the response - after it is returned by the SecuritySettingsService 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 SecuritySettingsService 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 SecuritySettingsService 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 SecuritySettingsService 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 SecuritySettingsService 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 SecuritySettingsService 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 SecuritySettingsService server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class SecuritySettingsServiceRestStub: - _session: AuthorizedSession - _host: str - _interceptor: SecuritySettingsServiceRestInterceptor - - -class SecuritySettingsServiceRestTransport(SecuritySettingsServiceTransport): - """REST backend transport for SecuritySettingsService. - - Service for managing security settings for Dialogflow. - - 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 = 'dialogflow.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[SecuritySettingsServiceRestInterceptor] = 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) - if client_cert_source_for_mtls: - self._session.configure_mtls_channel(client_cert_source_for_mtls) - self._interceptor = interceptor or SecuritySettingsServiceRestInterceptor() - self._prep_wrapped_messages(client_info) - - class _CreateSecuritySettings(SecuritySettingsServiceRestStub): - def __hash__(self): - return hash("CreateSecuritySettings") - - __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: gcdc_security_settings.CreateSecuritySettingsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_security_settings.SecuritySettings: - r"""Call the create security settings method over HTTP. - - Args: - request (~.gcdc_security_settings.CreateSecuritySettingsRequest): - The request object. The request message for - [SecuritySettings.CreateSecuritySettings][]. - 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: - ~.gcdc_security_settings.SecuritySettings: - Represents the settings related to - security issues, such as data redaction - and data retention. It may take hours - for updates on the settings to propagate - to all the related components and take - effect. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v3/{parent=projects/*/locations/*}/securitySettings', - 'body': 'security_settings', - }, - ] - request, metadata = self._interceptor.pre_create_security_settings(request, metadata) - pb_request = gcdc_security_settings.CreateSecuritySettingsRequest.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 = gcdc_security_settings.SecuritySettings() - pb_resp = gcdc_security_settings.SecuritySettings.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_security_settings(resp) - return resp - - class _DeleteSecuritySettings(SecuritySettingsServiceRestStub): - def __hash__(self): - return hash("DeleteSecuritySettings") - - __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: security_settings.DeleteSecuritySettingsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete security settings method over HTTP. - - Args: - request (~.security_settings.DeleteSecuritySettingsRequest): - The request object. The request message for - [SecuritySettings.DeleteSecuritySettings][]. - 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': '/v3/{name=projects/*/locations/*/securitySettings/*}', - }, - ] - request, metadata = self._interceptor.pre_delete_security_settings(request, metadata) - pb_request = security_settings.DeleteSecuritySettingsRequest.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 _GetSecuritySettings(SecuritySettingsServiceRestStub): - def __hash__(self): - return hash("GetSecuritySettings") - - __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: security_settings.GetSecuritySettingsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> security_settings.SecuritySettings: - r"""Call the get security settings method over HTTP. - - Args: - request (~.security_settings.GetSecuritySettingsRequest): - The request object. The request message for - [SecuritySettingsService.GetSecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettingsService.GetSecuritySettings]. - 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: - ~.security_settings.SecuritySettings: - Represents the settings related to - security issues, such as data redaction - and data retention. It may take hours - for updates on the settings to propagate - to all the related components and take - effect. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/securitySettings/*}', - }, - ] - request, metadata = self._interceptor.pre_get_security_settings(request, metadata) - pb_request = security_settings.GetSecuritySettingsRequest.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 = security_settings.SecuritySettings() - pb_resp = security_settings.SecuritySettings.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_security_settings(resp) - return resp - - class _ListSecuritySettings(SecuritySettingsServiceRestStub): - def __hash__(self): - return hash("ListSecuritySettings") - - __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: security_settings.ListSecuritySettingsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> security_settings.ListSecuritySettingsResponse: - r"""Call the list security settings method over HTTP. - - Args: - request (~.security_settings.ListSecuritySettingsRequest): - The request object. The request message for - [SecuritySettings.ListSecuritySettings][]. - 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: - ~.security_settings.ListSecuritySettingsResponse: - The response message for - [SecuritySettings.ListSecuritySettings][]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{parent=projects/*/locations/*}/securitySettings', - }, - ] - request, metadata = self._interceptor.pre_list_security_settings(request, metadata) - pb_request = security_settings.ListSecuritySettingsRequest.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 = security_settings.ListSecuritySettingsResponse() - pb_resp = security_settings.ListSecuritySettingsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_security_settings(resp) - return resp - - class _UpdateSecuritySettings(SecuritySettingsServiceRestStub): - def __hash__(self): - return hash("UpdateSecuritySettings") - - __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: gcdc_security_settings.UpdateSecuritySettingsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_security_settings.SecuritySettings: - r"""Call the update security settings method over HTTP. - - Args: - request (~.gcdc_security_settings.UpdateSecuritySettingsRequest): - The request object. The request message for - [SecuritySettingsService.UpdateSecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettingsService.UpdateSecuritySettings]. - 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: - ~.gcdc_security_settings.SecuritySettings: - Represents the settings related to - security issues, such as data redaction - and data retention. It may take hours - for updates on the settings to propagate - to all the related components and take - effect. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v3/{security_settings.name=projects/*/locations/*/securitySettings/*}', - 'body': 'security_settings', - }, - ] - request, metadata = self._interceptor.pre_update_security_settings(request, metadata) - pb_request = gcdc_security_settings.UpdateSecuritySettingsRequest.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 = gcdc_security_settings.SecuritySettings() - pb_resp = gcdc_security_settings.SecuritySettings.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_security_settings(resp) - return resp - - @property - def create_security_settings(self) -> Callable[ - [gcdc_security_settings.CreateSecuritySettingsRequest], - gcdc_security_settings.SecuritySettings]: - # 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._CreateSecuritySettings(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_security_settings(self) -> Callable[ - [security_settings.DeleteSecuritySettingsRequest], - 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._DeleteSecuritySettings(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_security_settings(self) -> Callable[ - [security_settings.GetSecuritySettingsRequest], - security_settings.SecuritySettings]: - # 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._GetSecuritySettings(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_security_settings(self) -> Callable[ - [security_settings.ListSecuritySettingsRequest], - security_settings.ListSecuritySettingsResponse]: - # 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._ListSecuritySettings(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_security_settings(self) -> Callable[ - [gcdc_security_settings.UpdateSecuritySettingsRequest], - gcdc_security_settings.SecuritySettings]: - # 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._UpdateSecuritySettings(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_location(self): - return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore - - class _GetLocation(SecuritySettingsServiceRestStub): - def __call__(self, - request: locations_pb2.GetLocationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.Location: - - r"""Call the get location method over HTTP. - - Args: - request (locations_pb2.GetLocationRequest): - The request object for GetLocation 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: - locations_pb2.Location: Response from GetLocation method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*}', - }, - ] - - request, metadata = self._interceptor.pre_get_location(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 = locations_pb2.Location() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_get_location(resp) - return resp - - @property - def list_locations(self): - return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore - - class _ListLocations(SecuritySettingsServiceRestStub): - def __call__(self, - request: locations_pb2.ListLocationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.ListLocationsResponse: - - r"""Call the list locations method over HTTP. - - Args: - request (locations_pb2.ListLocationsRequest): - The request object for ListLocations 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: - locations_pb2.ListLocationsResponse: Response from ListLocations method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*}/locations', - }, - ] - - request, metadata = self._interceptor.pre_list_locations(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 = locations_pb2.ListLocationsResponse() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_list_locations(resp) - return resp - - @property - def cancel_operation(self): - return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore - - class _CancelOperation(SecuritySettingsServiceRestStub): - 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': '/v3/{name=projects/*/operations/*}:cancel', - }, -{ - 'method': 'post', - 'uri': '/v3/{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(SecuritySettingsServiceRestStub): - 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': '/v3/{name=projects/*/operations/*}', - }, -{ - 'method': 'get', - 'uri': '/v3/{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(SecuritySettingsServiceRestStub): - 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': '/v3/{name=projects/*}/operations', - }, -{ - 'method': 'get', - 'uri': '/v3/{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__=( - 'SecuritySettingsServiceRestTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/__init__.py deleted file mode 100644 index febc5c92..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/__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 SessionEntityTypesClient -from .async_client import SessionEntityTypesAsyncClient - -__all__ = ( - 'SessionEntityTypesClient', - 'SessionEntityTypesAsyncClient', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/async_client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/async_client.py deleted file mode 100644 index 7e52857e..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/async_client.py +++ /dev/null @@ -1,1064 +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.dialogflowcx_v3 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.cloud.dialogflowcx_v3.services.session_entity_types import pagers -from google.cloud.dialogflowcx_v3.types import entity_type -from google.cloud.dialogflowcx_v3.types import session_entity_type -from google.cloud.dialogflowcx_v3.types import session_entity_type as gcdc_session_entity_type -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import SessionEntityTypesTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import SessionEntityTypesGrpcAsyncIOTransport -from .client import SessionEntityTypesClient - - -class SessionEntityTypesAsyncClient: - """Service for managing - [SessionEntityTypes][google.cloud.dialogflow.cx.v3.SessionEntityType]. - """ - - _client: SessionEntityTypesClient - - DEFAULT_ENDPOINT = SessionEntityTypesClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = SessionEntityTypesClient.DEFAULT_MTLS_ENDPOINT - - session_entity_type_path = staticmethod(SessionEntityTypesClient.session_entity_type_path) - parse_session_entity_type_path = staticmethod(SessionEntityTypesClient.parse_session_entity_type_path) - common_billing_account_path = staticmethod(SessionEntityTypesClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(SessionEntityTypesClient.parse_common_billing_account_path) - common_folder_path = staticmethod(SessionEntityTypesClient.common_folder_path) - parse_common_folder_path = staticmethod(SessionEntityTypesClient.parse_common_folder_path) - common_organization_path = staticmethod(SessionEntityTypesClient.common_organization_path) - parse_common_organization_path = staticmethod(SessionEntityTypesClient.parse_common_organization_path) - common_project_path = staticmethod(SessionEntityTypesClient.common_project_path) - parse_common_project_path = staticmethod(SessionEntityTypesClient.parse_common_project_path) - common_location_path = staticmethod(SessionEntityTypesClient.common_location_path) - parse_common_location_path = staticmethod(SessionEntityTypesClient.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: - SessionEntityTypesAsyncClient: The constructed client. - """ - return SessionEntityTypesClient.from_service_account_info.__func__(SessionEntityTypesAsyncClient, 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: - SessionEntityTypesAsyncClient: The constructed client. - """ - return SessionEntityTypesClient.from_service_account_file.__func__(SessionEntityTypesAsyncClient, 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 SessionEntityTypesClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> SessionEntityTypesTransport: - """Returns the transport used by the client instance. - - Returns: - SessionEntityTypesTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(SessionEntityTypesClient).get_transport_class, type(SessionEntityTypesClient)) - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, SessionEntityTypesTransport] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the session entity types 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, ~.SessionEntityTypesTransport]): 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 = SessionEntityTypesClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def list_session_entity_types(self, - request: Optional[Union[session_entity_type.ListSessionEntityTypesRequest, 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.ListSessionEntityTypesAsyncPager: - r"""Returns the list of all session entity types in the - specified session. - - .. 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 dialogflowcx_v3 - - async def sample_list_session_entity_types(): - # Create a client - client = dialogflowcx_v3.SessionEntityTypesAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListSessionEntityTypesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_session_entity_types(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ListSessionEntityTypesRequest, dict]]): - The request object. The request message for - [SessionEntityTypes.ListSessionEntityTypes][google.cloud.dialogflow.cx.v3.SessionEntityTypes.ListSessionEntityTypes]. - parent (:class:`str`): - Required. The session to list all session entity types - from. Format: - ``projects//locations//agents//sessions/`` - or - ``projects//locations//agents//environments//sessions/``. - If ``Environment ID`` is not specified, we assume - default 'draft' environment. - - 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.dialogflowcx_v3.services.session_entity_types.pagers.ListSessionEntityTypesAsyncPager: - The response message for - [SessionEntityTypes.ListSessionEntityTypes][google.cloud.dialogflow.cx.v3.SessionEntityTypes.ListSessionEntityTypes]. - - 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 = session_entity_type.ListSessionEntityTypesRequest(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_session_entity_types, - 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.ListSessionEntityTypesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_session_entity_type(self, - request: Optional[Union[session_entity_type.GetSessionEntityTypeRequest, 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]] = (), - ) -> session_entity_type.SessionEntityType: - r"""Retrieves the specified session entity type. - - .. 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 dialogflowcx_v3 - - async def sample_get_session_entity_type(): - # Create a client - client = dialogflowcx_v3.SessionEntityTypesAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetSessionEntityTypeRequest( - name="name_value", - ) - - # Make the request - response = await client.get_session_entity_type(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.GetSessionEntityTypeRequest, dict]]): - The request object. The request message for - [SessionEntityTypes.GetSessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityTypes.GetSessionEntityType]. - name (:class:`str`): - Required. The name of the session entity type. Format: - ``projects//locations//agents//sessions//entityTypes/`` - or - ``projects//locations//agents//environments//sessions//entityTypes/``. - If ``Environment ID`` is not specified, we assume - default 'draft' environment. - - 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.dialogflowcx_v3.types.SessionEntityType: - Session entity types are referred to as **User** entity types and are - entities that are built for an individual user such - as favorites, preferences, playlists, and so on. - - You can redefine a session entity type at the session - level to extend or replace a [custom entity - type][google.cloud.dialogflow.cx.v3.EntityType] at - the user session level (we refer to the entity types - defined at the agent level as "custom entity types"). - - Note: session entity types apply to all queries, - regardless of the language. - - For more information about entity types, see the - [Dialogflow - documentation](\ https://cloud.google.com/dialogflow/docs/entities-overview). - - """ - # 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 = session_entity_type.GetSessionEntityTypeRequest(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_session_entity_type, - 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 create_session_entity_type(self, - request: Optional[Union[gcdc_session_entity_type.CreateSessionEntityTypeRequest, dict]] = None, - *, - parent: Optional[str] = None, - session_entity_type: Optional[gcdc_session_entity_type.SessionEntityType] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_session_entity_type.SessionEntityType: - r"""Creates a session entity type. - - .. 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 dialogflowcx_v3 - - async def sample_create_session_entity_type(): - # Create a client - client = dialogflowcx_v3.SessionEntityTypesAsyncClient() - - # Initialize request argument(s) - session_entity_type = dialogflowcx_v3.SessionEntityType() - session_entity_type.name = "name_value" - session_entity_type.entity_override_mode = "ENTITY_OVERRIDE_MODE_SUPPLEMENT" - session_entity_type.entities.value = "value_value" - session_entity_type.entities.synonyms = ['synonyms_value1', 'synonyms_value2'] - - request = dialogflowcx_v3.CreateSessionEntityTypeRequest( - parent="parent_value", - session_entity_type=session_entity_type, - ) - - # Make the request - response = await client.create_session_entity_type(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.CreateSessionEntityTypeRequest, dict]]): - The request object. The request message for - [SessionEntityTypes.CreateSessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityTypes.CreateSessionEntityType]. - parent (:class:`str`): - Required. The session to create a session entity type - for. Format: - ``projects//locations//agents//sessions/`` - or - ``projects//locations//agents//environments//sessions/``. - If ``Environment ID`` is not specified, we assume - default 'draft' environment. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - session_entity_type (:class:`google.cloud.dialogflowcx_v3.types.SessionEntityType`): - Required. The session entity type to - create. - - This corresponds to the ``session_entity_type`` 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.dialogflowcx_v3.types.SessionEntityType: - Session entity types are referred to as **User** entity types and are - entities that are built for an individual user such - as favorites, preferences, playlists, and so on. - - You can redefine a session entity type at the session - level to extend or replace a [custom entity - type][google.cloud.dialogflow.cx.v3.EntityType] at - the user session level (we refer to the entity types - defined at the agent level as "custom entity types"). - - Note: session entity types apply to all queries, - regardless of the language. - - For more information about entity types, see the - [Dialogflow - documentation](\ https://cloud.google.com/dialogflow/docs/entities-overview). - - """ - # 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, session_entity_type]) - 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 = gcdc_session_entity_type.CreateSessionEntityTypeRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if session_entity_type is not None: - request.session_entity_type = session_entity_type - - # 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_session_entity_type, - 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_session_entity_type(self, - request: Optional[Union[gcdc_session_entity_type.UpdateSessionEntityTypeRequest, dict]] = None, - *, - session_entity_type: Optional[gcdc_session_entity_type.SessionEntityType] = 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]] = (), - ) -> gcdc_session_entity_type.SessionEntityType: - r"""Updates the specified session entity type. - - .. 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 dialogflowcx_v3 - - async def sample_update_session_entity_type(): - # Create a client - client = dialogflowcx_v3.SessionEntityTypesAsyncClient() - - # Initialize request argument(s) - session_entity_type = dialogflowcx_v3.SessionEntityType() - session_entity_type.name = "name_value" - session_entity_type.entity_override_mode = "ENTITY_OVERRIDE_MODE_SUPPLEMENT" - session_entity_type.entities.value = "value_value" - session_entity_type.entities.synonyms = ['synonyms_value1', 'synonyms_value2'] - - request = dialogflowcx_v3.UpdateSessionEntityTypeRequest( - session_entity_type=session_entity_type, - ) - - # Make the request - response = await client.update_session_entity_type(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.UpdateSessionEntityTypeRequest, dict]]): - The request object. The request message for - [SessionEntityTypes.UpdateSessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityTypes.UpdateSessionEntityType]. - session_entity_type (:class:`google.cloud.dialogflowcx_v3.types.SessionEntityType`): - Required. The session entity type to update. Format: - ``projects//locations//agents//sessions//entityTypes/`` - or - ``projects//locations//agents//environments//sessions//entityTypes/``. - If ``Environment ID`` is not specified, we assume - default 'draft' environment. - - This corresponds to the ``session_entity_type`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The mask to control which fields get - 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.dialogflowcx_v3.types.SessionEntityType: - Session entity types are referred to as **User** entity types and are - entities that are built for an individual user such - as favorites, preferences, playlists, and so on. - - You can redefine a session entity type at the session - level to extend or replace a [custom entity - type][google.cloud.dialogflow.cx.v3.EntityType] at - the user session level (we refer to the entity types - defined at the agent level as "custom entity types"). - - Note: session entity types apply to all queries, - regardless of the language. - - For more information about entity types, see the - [Dialogflow - documentation](\ https://cloud.google.com/dialogflow/docs/entities-overview). - - """ - # 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([session_entity_type, 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 = gcdc_session_entity_type.UpdateSessionEntityTypeRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if session_entity_type is not None: - request.session_entity_type = session_entity_type - 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_session_entity_type, - 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(( - ("session_entity_type.name", request.session_entity_type.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_session_entity_type(self, - request: Optional[Union[session_entity_type.DeleteSessionEntityTypeRequest, 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 the specified session entity type. - - .. 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 dialogflowcx_v3 - - async def sample_delete_session_entity_type(): - # Create a client - client = dialogflowcx_v3.SessionEntityTypesAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteSessionEntityTypeRequest( - name="name_value", - ) - - # Make the request - await client.delete_session_entity_type(request=request) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.DeleteSessionEntityTypeRequest, dict]]): - The request object. The request message for - [SessionEntityTypes.DeleteSessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityTypes.DeleteSessionEntityType]. - name (:class:`str`): - Required. The name of the session entity type to delete. - Format: - ``projects//locations//agents//sessions//entityTypes/`` - or - ``projects//locations//agents//environments//sessions//entityTypes/``. - If ``Environment ID`` is not specified, we assume - default 'draft' environment. - - 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 = session_entity_type.DeleteSessionEntityTypeRequest(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_session_entity_type, - 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 get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**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_location, - 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_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**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_locations, - 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 __aenter__(self) -> "SessionEntityTypesAsyncClient": - 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__ = ( - "SessionEntityTypesAsyncClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/client.py deleted file mode 100644 index 69bb9f3d..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/client.py +++ /dev/null @@ -1,1263 +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.dialogflowcx_v3 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.cloud.dialogflowcx_v3.services.session_entity_types import pagers -from google.cloud.dialogflowcx_v3.types import entity_type -from google.cloud.dialogflowcx_v3.types import session_entity_type -from google.cloud.dialogflowcx_v3.types import session_entity_type as gcdc_session_entity_type -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import SessionEntityTypesTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import SessionEntityTypesGrpcTransport -from .transports.grpc_asyncio import SessionEntityTypesGrpcAsyncIOTransport -from .transports.rest import SessionEntityTypesRestTransport - - -class SessionEntityTypesClientMeta(type): - """Metaclass for the SessionEntityTypes 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[SessionEntityTypesTransport]] - _transport_registry["grpc"] = SessionEntityTypesGrpcTransport - _transport_registry["grpc_asyncio"] = SessionEntityTypesGrpcAsyncIOTransport - _transport_registry["rest"] = SessionEntityTypesRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[SessionEntityTypesTransport]: - """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 SessionEntityTypesClient(metaclass=SessionEntityTypesClientMeta): - """Service for managing - [SessionEntityTypes][google.cloud.dialogflow.cx.v3.SessionEntityType]. - """ - - @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 = "dialogflow.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: - SessionEntityTypesClient: 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: - SessionEntityTypesClient: 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) -> SessionEntityTypesTransport: - """Returns the transport used by the client instance. - - Returns: - SessionEntityTypesTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def session_entity_type_path(project: str,location: str,agent: str,session: str,entity_type: str,) -> str: - """Returns a fully-qualified session_entity_type string.""" - return "projects/{project}/locations/{location}/agents/{agent}/sessions/{session}/entityTypes/{entity_type}".format(project=project, location=location, agent=agent, session=session, entity_type=entity_type, ) - - @staticmethod - def parse_session_entity_type_path(path: str) -> Dict[str,str]: - """Parses a session_entity_type path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/sessions/(?P.+?)/entityTypes/(?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, SessionEntityTypesTransport]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the session entity types 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, SessionEntityTypesTransport]): 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, SessionEntityTypesTransport): - # transport is a SessionEntityTypesTransport 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 list_session_entity_types(self, - request: Optional[Union[session_entity_type.ListSessionEntityTypesRequest, 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.ListSessionEntityTypesPager: - r"""Returns the list of all session entity types in the - specified session. - - .. 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 dialogflowcx_v3 - - def sample_list_session_entity_types(): - # Create a client - client = dialogflowcx_v3.SessionEntityTypesClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListSessionEntityTypesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_session_entity_types(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ListSessionEntityTypesRequest, dict]): - The request object. The request message for - [SessionEntityTypes.ListSessionEntityTypes][google.cloud.dialogflow.cx.v3.SessionEntityTypes.ListSessionEntityTypes]. - parent (str): - Required. The session to list all session entity types - from. Format: - ``projects//locations//agents//sessions/`` - or - ``projects//locations//agents//environments//sessions/``. - If ``Environment ID`` is not specified, we assume - default 'draft' environment. - - 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.dialogflowcx_v3.services.session_entity_types.pagers.ListSessionEntityTypesPager: - The response message for - [SessionEntityTypes.ListSessionEntityTypes][google.cloud.dialogflow.cx.v3.SessionEntityTypes.ListSessionEntityTypes]. - - 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 session_entity_type.ListSessionEntityTypesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, session_entity_type.ListSessionEntityTypesRequest): - request = session_entity_type.ListSessionEntityTypesRequest(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_session_entity_types] - - # 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.ListSessionEntityTypesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_session_entity_type(self, - request: Optional[Union[session_entity_type.GetSessionEntityTypeRequest, 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]] = (), - ) -> session_entity_type.SessionEntityType: - r"""Retrieves the specified session entity type. - - .. 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 dialogflowcx_v3 - - def sample_get_session_entity_type(): - # Create a client - client = dialogflowcx_v3.SessionEntityTypesClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetSessionEntityTypeRequest( - name="name_value", - ) - - # Make the request - response = client.get_session_entity_type(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.GetSessionEntityTypeRequest, dict]): - The request object. The request message for - [SessionEntityTypes.GetSessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityTypes.GetSessionEntityType]. - name (str): - Required. The name of the session entity type. Format: - ``projects//locations//agents//sessions//entityTypes/`` - or - ``projects//locations//agents//environments//sessions//entityTypes/``. - If ``Environment ID`` is not specified, we assume - default 'draft' environment. - - 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.dialogflowcx_v3.types.SessionEntityType: - Session entity types are referred to as **User** entity types and are - entities that are built for an individual user such - as favorites, preferences, playlists, and so on. - - You can redefine a session entity type at the session - level to extend or replace a [custom entity - type][google.cloud.dialogflow.cx.v3.EntityType] at - the user session level (we refer to the entity types - defined at the agent level as "custom entity types"). - - Note: session entity types apply to all queries, - regardless of the language. - - For more information about entity types, see the - [Dialogflow - documentation](\ https://cloud.google.com/dialogflow/docs/entities-overview). - - """ - # 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 session_entity_type.GetSessionEntityTypeRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, session_entity_type.GetSessionEntityTypeRequest): - request = session_entity_type.GetSessionEntityTypeRequest(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_session_entity_type] - - # 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 create_session_entity_type(self, - request: Optional[Union[gcdc_session_entity_type.CreateSessionEntityTypeRequest, dict]] = None, - *, - parent: Optional[str] = None, - session_entity_type: Optional[gcdc_session_entity_type.SessionEntityType] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_session_entity_type.SessionEntityType: - r"""Creates a session entity type. - - .. 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 dialogflowcx_v3 - - def sample_create_session_entity_type(): - # Create a client - client = dialogflowcx_v3.SessionEntityTypesClient() - - # Initialize request argument(s) - session_entity_type = dialogflowcx_v3.SessionEntityType() - session_entity_type.name = "name_value" - session_entity_type.entity_override_mode = "ENTITY_OVERRIDE_MODE_SUPPLEMENT" - session_entity_type.entities.value = "value_value" - session_entity_type.entities.synonyms = ['synonyms_value1', 'synonyms_value2'] - - request = dialogflowcx_v3.CreateSessionEntityTypeRequest( - parent="parent_value", - session_entity_type=session_entity_type, - ) - - # Make the request - response = client.create_session_entity_type(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.CreateSessionEntityTypeRequest, dict]): - The request object. The request message for - [SessionEntityTypes.CreateSessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityTypes.CreateSessionEntityType]. - parent (str): - Required. The session to create a session entity type - for. Format: - ``projects//locations//agents//sessions/`` - or - ``projects//locations//agents//environments//sessions/``. - If ``Environment ID`` is not specified, we assume - default 'draft' environment. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - session_entity_type (google.cloud.dialogflowcx_v3.types.SessionEntityType): - Required. The session entity type to - create. - - This corresponds to the ``session_entity_type`` 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.dialogflowcx_v3.types.SessionEntityType: - Session entity types are referred to as **User** entity types and are - entities that are built for an individual user such - as favorites, preferences, playlists, and so on. - - You can redefine a session entity type at the session - level to extend or replace a [custom entity - type][google.cloud.dialogflow.cx.v3.EntityType] at - the user session level (we refer to the entity types - defined at the agent level as "custom entity types"). - - Note: session entity types apply to all queries, - regardless of the language. - - For more information about entity types, see the - [Dialogflow - documentation](\ https://cloud.google.com/dialogflow/docs/entities-overview). - - """ - # 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, session_entity_type]) - 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 gcdc_session_entity_type.CreateSessionEntityTypeRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_session_entity_type.CreateSessionEntityTypeRequest): - request = gcdc_session_entity_type.CreateSessionEntityTypeRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if session_entity_type is not None: - request.session_entity_type = session_entity_type - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_session_entity_type] - - # 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_session_entity_type(self, - request: Optional[Union[gcdc_session_entity_type.UpdateSessionEntityTypeRequest, dict]] = None, - *, - session_entity_type: Optional[gcdc_session_entity_type.SessionEntityType] = 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]] = (), - ) -> gcdc_session_entity_type.SessionEntityType: - r"""Updates the specified session entity type. - - .. 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 dialogflowcx_v3 - - def sample_update_session_entity_type(): - # Create a client - client = dialogflowcx_v3.SessionEntityTypesClient() - - # Initialize request argument(s) - session_entity_type = dialogflowcx_v3.SessionEntityType() - session_entity_type.name = "name_value" - session_entity_type.entity_override_mode = "ENTITY_OVERRIDE_MODE_SUPPLEMENT" - session_entity_type.entities.value = "value_value" - session_entity_type.entities.synonyms = ['synonyms_value1', 'synonyms_value2'] - - request = dialogflowcx_v3.UpdateSessionEntityTypeRequest( - session_entity_type=session_entity_type, - ) - - # Make the request - response = client.update_session_entity_type(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.UpdateSessionEntityTypeRequest, dict]): - The request object. The request message for - [SessionEntityTypes.UpdateSessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityTypes.UpdateSessionEntityType]. - session_entity_type (google.cloud.dialogflowcx_v3.types.SessionEntityType): - Required. The session entity type to update. Format: - ``projects//locations//agents//sessions//entityTypes/`` - or - ``projects//locations//agents//environments//sessions//entityTypes/``. - If ``Environment ID`` is not specified, we assume - default 'draft' environment. - - This corresponds to the ``session_entity_type`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The mask to control which fields get - 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.dialogflowcx_v3.types.SessionEntityType: - Session entity types are referred to as **User** entity types and are - entities that are built for an individual user such - as favorites, preferences, playlists, and so on. - - You can redefine a session entity type at the session - level to extend or replace a [custom entity - type][google.cloud.dialogflow.cx.v3.EntityType] at - the user session level (we refer to the entity types - defined at the agent level as "custom entity types"). - - Note: session entity types apply to all queries, - regardless of the language. - - For more information about entity types, see the - [Dialogflow - documentation](\ https://cloud.google.com/dialogflow/docs/entities-overview). - - """ - # 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([session_entity_type, 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 gcdc_session_entity_type.UpdateSessionEntityTypeRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_session_entity_type.UpdateSessionEntityTypeRequest): - request = gcdc_session_entity_type.UpdateSessionEntityTypeRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if session_entity_type is not None: - request.session_entity_type = session_entity_type - 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_session_entity_type] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("session_entity_type.name", request.session_entity_type.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_session_entity_type(self, - request: Optional[Union[session_entity_type.DeleteSessionEntityTypeRequest, 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 the specified session entity type. - - .. 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 dialogflowcx_v3 - - def sample_delete_session_entity_type(): - # Create a client - client = dialogflowcx_v3.SessionEntityTypesClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteSessionEntityTypeRequest( - name="name_value", - ) - - # Make the request - client.delete_session_entity_type(request=request) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.DeleteSessionEntityTypeRequest, dict]): - The request object. The request message for - [SessionEntityTypes.DeleteSessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityTypes.DeleteSessionEntityType]. - name (str): - Required. The name of the session entity type to delete. - Format: - ``projects//locations//agents//sessions//entityTypes/`` - or - ``projects//locations//agents//environments//sessions//entityTypes/``. - If ``Environment ID`` is not specified, we assume - default 'draft' environment. - - 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 session_entity_type.DeleteSessionEntityTypeRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, session_entity_type.DeleteSessionEntityTypeRequest): - request = session_entity_type.DeleteSessionEntityTypeRequest(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_session_entity_type] - - # 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) -> "SessionEntityTypesClient": - 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,) - - def get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.get_location, - 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 list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.list_locations, - 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 - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "SessionEntityTypesClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/pagers.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/pagers.py deleted file mode 100644 index 32f93aa3..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/pagers.py +++ /dev/null @@ -1,139 +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.dialogflowcx_v3.types import session_entity_type - - -class ListSessionEntityTypesPager: - """A pager for iterating through ``list_session_entity_types`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListSessionEntityTypesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``session_entity_types`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListSessionEntityTypes`` requests and continue to iterate - through the ``session_entity_types`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListSessionEntityTypesResponse` - 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[..., session_entity_type.ListSessionEntityTypesResponse], - request: session_entity_type.ListSessionEntityTypesRequest, - response: session_entity_type.ListSessionEntityTypesResponse, - *, - 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.dialogflowcx_v3.types.ListSessionEntityTypesRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListSessionEntityTypesResponse): - 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 = session_entity_type.ListSessionEntityTypesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[session_entity_type.ListSessionEntityTypesResponse]: - 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[session_entity_type.SessionEntityType]: - for page in self.pages: - yield from page.session_entity_types - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListSessionEntityTypesAsyncPager: - """A pager for iterating through ``list_session_entity_types`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListSessionEntityTypesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``session_entity_types`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListSessionEntityTypes`` requests and continue to iterate - through the ``session_entity_types`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListSessionEntityTypesResponse` - 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[session_entity_type.ListSessionEntityTypesResponse]], - request: session_entity_type.ListSessionEntityTypesRequest, - response: session_entity_type.ListSessionEntityTypesResponse, - *, - 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.dialogflowcx_v3.types.ListSessionEntityTypesRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListSessionEntityTypesResponse): - 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 = session_entity_type.ListSessionEntityTypesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[session_entity_type.ListSessionEntityTypesResponse]: - 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[session_entity_type.SessionEntityType]: - async def async_generator(): - async for page in self.pages: - for response in page.session_entity_types: - 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/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/__init__.py deleted file mode 100644 index 369e14ad..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/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 SessionEntityTypesTransport -from .grpc import SessionEntityTypesGrpcTransport -from .grpc_asyncio import SessionEntityTypesGrpcAsyncIOTransport -from .rest import SessionEntityTypesRestTransport -from .rest import SessionEntityTypesRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[SessionEntityTypesTransport]] -_transport_registry['grpc'] = SessionEntityTypesGrpcTransport -_transport_registry['grpc_asyncio'] = SessionEntityTypesGrpcAsyncIOTransport -_transport_registry['rest'] = SessionEntityTypesRestTransport - -__all__ = ( - 'SessionEntityTypesTransport', - 'SessionEntityTypesGrpcTransport', - 'SessionEntityTypesGrpcAsyncIOTransport', - 'SessionEntityTypesRestTransport', - 'SessionEntityTypesRestInterceptor', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/base.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/base.py deleted file mode 100644 index 27e2bf38..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/base.py +++ /dev/null @@ -1,252 +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.dialogflowcx_v3 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.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.dialogflowcx_v3.types import session_entity_type -from google.cloud.dialogflowcx_v3.types import session_entity_type as gcdc_session_entity_type -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -class SessionEntityTypesTransport(abc.ABC): - """Abstract transport class for SessionEntityTypes.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/dialogflow', - ) - - DEFAULT_HOST: str = 'dialogflow.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.list_session_entity_types: gapic_v1.method.wrap_method( - self.list_session_entity_types, - default_timeout=None, - client_info=client_info, - ), - self.get_session_entity_type: gapic_v1.method.wrap_method( - self.get_session_entity_type, - default_timeout=None, - client_info=client_info, - ), - self.create_session_entity_type: gapic_v1.method.wrap_method( - self.create_session_entity_type, - default_timeout=None, - client_info=client_info, - ), - self.update_session_entity_type: gapic_v1.method.wrap_method( - self.update_session_entity_type, - default_timeout=None, - client_info=client_info, - ), - self.delete_session_entity_type: gapic_v1.method.wrap_method( - self.delete_session_entity_type, - 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 list_session_entity_types(self) -> Callable[ - [session_entity_type.ListSessionEntityTypesRequest], - Union[ - session_entity_type.ListSessionEntityTypesResponse, - Awaitable[session_entity_type.ListSessionEntityTypesResponse] - ]]: - raise NotImplementedError() - - @property - def get_session_entity_type(self) -> Callable[ - [session_entity_type.GetSessionEntityTypeRequest], - Union[ - session_entity_type.SessionEntityType, - Awaitable[session_entity_type.SessionEntityType] - ]]: - raise NotImplementedError() - - @property - def create_session_entity_type(self) -> Callable[ - [gcdc_session_entity_type.CreateSessionEntityTypeRequest], - Union[ - gcdc_session_entity_type.SessionEntityType, - Awaitable[gcdc_session_entity_type.SessionEntityType] - ]]: - raise NotImplementedError() - - @property - def update_session_entity_type(self) -> Callable[ - [gcdc_session_entity_type.UpdateSessionEntityTypeRequest], - Union[ - gcdc_session_entity_type.SessionEntityType, - Awaitable[gcdc_session_entity_type.SessionEntityType] - ]]: - raise NotImplementedError() - - @property - def delete_session_entity_type(self) -> Callable[ - [session_entity_type.DeleteSessionEntityTypeRequest], - 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 get_location(self, - ) -> Callable[ - [locations_pb2.GetLocationRequest], - Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], - ]: - raise NotImplementedError() - - @property - def list_locations(self, - ) -> Callable[ - [locations_pb2.ListLocationsRequest], - Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'SessionEntityTypesTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/grpc.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/grpc.py deleted file mode 100644 index e3254361..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/grpc.py +++ /dev/null @@ -1,464 +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 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.dialogflowcx_v3.types import session_entity_type -from google.cloud.dialogflowcx_v3.types import session_entity_type as gcdc_session_entity_type -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from .base import SessionEntityTypesTransport, DEFAULT_CLIENT_INFO - - -class SessionEntityTypesGrpcTransport(SessionEntityTypesTransport): - """gRPC backend transport for SessionEntityTypes. - - Service for managing - [SessionEntityTypes][google.cloud.dialogflow.cx.v3.SessionEntityType]. - - 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 = 'dialogflow.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] = {} - - 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 = 'dialogflow.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 list_session_entity_types(self) -> Callable[ - [session_entity_type.ListSessionEntityTypesRequest], - session_entity_type.ListSessionEntityTypesResponse]: - r"""Return a callable for the list session entity types method over gRPC. - - Returns the list of all session entity types in the - specified session. - - Returns: - Callable[[~.ListSessionEntityTypesRequest], - ~.ListSessionEntityTypesResponse]: - 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_session_entity_types' not in self._stubs: - self._stubs['list_session_entity_types'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.SessionEntityTypes/ListSessionEntityTypes', - request_serializer=session_entity_type.ListSessionEntityTypesRequest.serialize, - response_deserializer=session_entity_type.ListSessionEntityTypesResponse.deserialize, - ) - return self._stubs['list_session_entity_types'] - - @property - def get_session_entity_type(self) -> Callable[ - [session_entity_type.GetSessionEntityTypeRequest], - session_entity_type.SessionEntityType]: - r"""Return a callable for the get session entity type method over gRPC. - - Retrieves the specified session entity type. - - Returns: - Callable[[~.GetSessionEntityTypeRequest], - ~.SessionEntityType]: - 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_session_entity_type' not in self._stubs: - self._stubs['get_session_entity_type'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.SessionEntityTypes/GetSessionEntityType', - request_serializer=session_entity_type.GetSessionEntityTypeRequest.serialize, - response_deserializer=session_entity_type.SessionEntityType.deserialize, - ) - return self._stubs['get_session_entity_type'] - - @property - def create_session_entity_type(self) -> Callable[ - [gcdc_session_entity_type.CreateSessionEntityTypeRequest], - gcdc_session_entity_type.SessionEntityType]: - r"""Return a callable for the create session entity type method over gRPC. - - Creates a session entity type. - - Returns: - Callable[[~.CreateSessionEntityTypeRequest], - ~.SessionEntityType]: - 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_session_entity_type' not in self._stubs: - self._stubs['create_session_entity_type'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.SessionEntityTypes/CreateSessionEntityType', - request_serializer=gcdc_session_entity_type.CreateSessionEntityTypeRequest.serialize, - response_deserializer=gcdc_session_entity_type.SessionEntityType.deserialize, - ) - return self._stubs['create_session_entity_type'] - - @property - def update_session_entity_type(self) -> Callable[ - [gcdc_session_entity_type.UpdateSessionEntityTypeRequest], - gcdc_session_entity_type.SessionEntityType]: - r"""Return a callable for the update session entity type method over gRPC. - - Updates the specified session entity type. - - Returns: - Callable[[~.UpdateSessionEntityTypeRequest], - ~.SessionEntityType]: - 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_session_entity_type' not in self._stubs: - self._stubs['update_session_entity_type'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.SessionEntityTypes/UpdateSessionEntityType', - request_serializer=gcdc_session_entity_type.UpdateSessionEntityTypeRequest.serialize, - response_deserializer=gcdc_session_entity_type.SessionEntityType.deserialize, - ) - return self._stubs['update_session_entity_type'] - - @property - def delete_session_entity_type(self) -> Callable[ - [session_entity_type.DeleteSessionEntityTypeRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete session entity type method over gRPC. - - Deletes the specified session entity type. - - Returns: - Callable[[~.DeleteSessionEntityTypeRequest], - ~.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_session_entity_type' not in self._stubs: - self._stubs['delete_session_entity_type'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.SessionEntityTypes/DeleteSessionEntityType', - request_serializer=session_entity_type.DeleteSessionEntityTypeRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_session_entity_type'] - - 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 list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'SessionEntityTypesGrpcTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/grpc_asyncio.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/grpc_asyncio.py deleted file mode 100644 index 3fbd77f5..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/grpc_asyncio.py +++ /dev/null @@ -1,463 +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.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.dialogflowcx_v3.types import session_entity_type -from google.cloud.dialogflowcx_v3.types import session_entity_type as gcdc_session_entity_type -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from .base import SessionEntityTypesTransport, DEFAULT_CLIENT_INFO -from .grpc import SessionEntityTypesGrpcTransport - - -class SessionEntityTypesGrpcAsyncIOTransport(SessionEntityTypesTransport): - """gRPC AsyncIO backend transport for SessionEntityTypes. - - Service for managing - [SessionEntityTypes][google.cloud.dialogflow.cx.v3.SessionEntityType]. - - 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 = 'dialogflow.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 = 'dialogflow.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] = {} - - 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 list_session_entity_types(self) -> Callable[ - [session_entity_type.ListSessionEntityTypesRequest], - Awaitable[session_entity_type.ListSessionEntityTypesResponse]]: - r"""Return a callable for the list session entity types method over gRPC. - - Returns the list of all session entity types in the - specified session. - - Returns: - Callable[[~.ListSessionEntityTypesRequest], - Awaitable[~.ListSessionEntityTypesResponse]]: - 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_session_entity_types' not in self._stubs: - self._stubs['list_session_entity_types'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.SessionEntityTypes/ListSessionEntityTypes', - request_serializer=session_entity_type.ListSessionEntityTypesRequest.serialize, - response_deserializer=session_entity_type.ListSessionEntityTypesResponse.deserialize, - ) - return self._stubs['list_session_entity_types'] - - @property - def get_session_entity_type(self) -> Callable[ - [session_entity_type.GetSessionEntityTypeRequest], - Awaitable[session_entity_type.SessionEntityType]]: - r"""Return a callable for the get session entity type method over gRPC. - - Retrieves the specified session entity type. - - Returns: - Callable[[~.GetSessionEntityTypeRequest], - Awaitable[~.SessionEntityType]]: - 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_session_entity_type' not in self._stubs: - self._stubs['get_session_entity_type'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.SessionEntityTypes/GetSessionEntityType', - request_serializer=session_entity_type.GetSessionEntityTypeRequest.serialize, - response_deserializer=session_entity_type.SessionEntityType.deserialize, - ) - return self._stubs['get_session_entity_type'] - - @property - def create_session_entity_type(self) -> Callable[ - [gcdc_session_entity_type.CreateSessionEntityTypeRequest], - Awaitable[gcdc_session_entity_type.SessionEntityType]]: - r"""Return a callable for the create session entity type method over gRPC. - - Creates a session entity type. - - Returns: - Callable[[~.CreateSessionEntityTypeRequest], - Awaitable[~.SessionEntityType]]: - 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_session_entity_type' not in self._stubs: - self._stubs['create_session_entity_type'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.SessionEntityTypes/CreateSessionEntityType', - request_serializer=gcdc_session_entity_type.CreateSessionEntityTypeRequest.serialize, - response_deserializer=gcdc_session_entity_type.SessionEntityType.deserialize, - ) - return self._stubs['create_session_entity_type'] - - @property - def update_session_entity_type(self) -> Callable[ - [gcdc_session_entity_type.UpdateSessionEntityTypeRequest], - Awaitable[gcdc_session_entity_type.SessionEntityType]]: - r"""Return a callable for the update session entity type method over gRPC. - - Updates the specified session entity type. - - Returns: - Callable[[~.UpdateSessionEntityTypeRequest], - Awaitable[~.SessionEntityType]]: - 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_session_entity_type' not in self._stubs: - self._stubs['update_session_entity_type'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.SessionEntityTypes/UpdateSessionEntityType', - request_serializer=gcdc_session_entity_type.UpdateSessionEntityTypeRequest.serialize, - response_deserializer=gcdc_session_entity_type.SessionEntityType.deserialize, - ) - return self._stubs['update_session_entity_type'] - - @property - def delete_session_entity_type(self) -> Callable[ - [session_entity_type.DeleteSessionEntityTypeRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete session entity type method over gRPC. - - Deletes the specified session entity type. - - Returns: - Callable[[~.DeleteSessionEntityTypeRequest], - 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_session_entity_type' not in self._stubs: - self._stubs['delete_session_entity_type'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.SessionEntityTypes/DeleteSessionEntityType', - request_serializer=session_entity_type.DeleteSessionEntityTypeRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_session_entity_type'] - - 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"] - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - -__all__ = ( - 'SessionEntityTypesGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/rest.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/rest.py deleted file mode 100644 index 62a7d6c5..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/rest.py +++ /dev/null @@ -1,1242 +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.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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.dialogflowcx_v3.types import session_entity_type -from google.cloud.dialogflowcx_v3.types import session_entity_type as gcdc_session_entity_type -from google.protobuf import empty_pb2 # type: ignore - -from .base import SessionEntityTypesTransport, 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 SessionEntityTypesRestInterceptor: - """Interceptor for SessionEntityTypes. - - 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 SessionEntityTypesRestTransport. - - .. code-block:: python - class MyCustomSessionEntityTypesInterceptor(SessionEntityTypesRestInterceptor): - def pre_create_session_entity_type(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_session_entity_type(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_session_entity_type(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_get_session_entity_type(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_session_entity_type(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_session_entity_types(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_session_entity_types(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_session_entity_type(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_session_entity_type(self, response): - logging.log(f"Received response: {response}") - return response - - transport = SessionEntityTypesRestTransport(interceptor=MyCustomSessionEntityTypesInterceptor()) - client = SessionEntityTypesClient(transport=transport) - - - """ - def pre_create_session_entity_type(self, request: gcdc_session_entity_type.CreateSessionEntityTypeRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_session_entity_type.CreateSessionEntityTypeRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_session_entity_type - - Override in a subclass to manipulate the request or metadata - before they are sent to the SessionEntityTypes server. - """ - return request, metadata - - def post_create_session_entity_type(self, response: gcdc_session_entity_type.SessionEntityType) -> gcdc_session_entity_type.SessionEntityType: - """Post-rpc interceptor for create_session_entity_type - - Override in a subclass to manipulate the response - after it is returned by the SessionEntityTypes server but before - it is returned to user code. - """ - return response - def pre_delete_session_entity_type(self, request: session_entity_type.DeleteSessionEntityTypeRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[session_entity_type.DeleteSessionEntityTypeRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_session_entity_type - - Override in a subclass to manipulate the request or metadata - before they are sent to the SessionEntityTypes server. - """ - return request, metadata - - def pre_get_session_entity_type(self, request: session_entity_type.GetSessionEntityTypeRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[session_entity_type.GetSessionEntityTypeRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_session_entity_type - - Override in a subclass to manipulate the request or metadata - before they are sent to the SessionEntityTypes server. - """ - return request, metadata - - def post_get_session_entity_type(self, response: session_entity_type.SessionEntityType) -> session_entity_type.SessionEntityType: - """Post-rpc interceptor for get_session_entity_type - - Override in a subclass to manipulate the response - after it is returned by the SessionEntityTypes server but before - it is returned to user code. - """ - return response - def pre_list_session_entity_types(self, request: session_entity_type.ListSessionEntityTypesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[session_entity_type.ListSessionEntityTypesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_session_entity_types - - Override in a subclass to manipulate the request or metadata - before they are sent to the SessionEntityTypes server. - """ - return request, metadata - - def post_list_session_entity_types(self, response: session_entity_type.ListSessionEntityTypesResponse) -> session_entity_type.ListSessionEntityTypesResponse: - """Post-rpc interceptor for list_session_entity_types - - Override in a subclass to manipulate the response - after it is returned by the SessionEntityTypes server but before - it is returned to user code. - """ - return response - def pre_update_session_entity_type(self, request: gcdc_session_entity_type.UpdateSessionEntityTypeRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_session_entity_type.UpdateSessionEntityTypeRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_session_entity_type - - Override in a subclass to manipulate the request or metadata - before they are sent to the SessionEntityTypes server. - """ - return request, metadata - - def post_update_session_entity_type(self, response: gcdc_session_entity_type.SessionEntityType) -> gcdc_session_entity_type.SessionEntityType: - """Post-rpc interceptor for update_session_entity_type - - Override in a subclass to manipulate the response - after it is returned by the SessionEntityTypes server but before - it is returned to user code. - """ - return response - - def pre_get_location( - self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_location - - Override in a subclass to manipulate the request or metadata - before they are sent to the SessionEntityTypes server. - """ - return request, metadata - - def post_get_location( - self, response: locations_pb2.Location - ) -> locations_pb2.Location: - """Post-rpc interceptor for get_location - - Override in a subclass to manipulate the response - after it is returned by the SessionEntityTypes server but before - it is returned to user code. - """ - return response - def pre_list_locations( - self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_locations - - Override in a subclass to manipulate the request or metadata - before they are sent to the SessionEntityTypes server. - """ - return request, metadata - - def post_list_locations( - self, response: locations_pb2.ListLocationsResponse - ) -> locations_pb2.ListLocationsResponse: - """Post-rpc interceptor for list_locations - - Override in a subclass to manipulate the response - after it is returned by the SessionEntityTypes 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 SessionEntityTypes 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 SessionEntityTypes 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 SessionEntityTypes 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 SessionEntityTypes 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 SessionEntityTypes 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 SessionEntityTypes server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class SessionEntityTypesRestStub: - _session: AuthorizedSession - _host: str - _interceptor: SessionEntityTypesRestInterceptor - - -class SessionEntityTypesRestTransport(SessionEntityTypesTransport): - """REST backend transport for SessionEntityTypes. - - Service for managing - [SessionEntityTypes][google.cloud.dialogflow.cx.v3.SessionEntityType]. - - 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 = 'dialogflow.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[SessionEntityTypesRestInterceptor] = 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) - if client_cert_source_for_mtls: - self._session.configure_mtls_channel(client_cert_source_for_mtls) - self._interceptor = interceptor or SessionEntityTypesRestInterceptor() - self._prep_wrapped_messages(client_info) - - class _CreateSessionEntityType(SessionEntityTypesRestStub): - def __hash__(self): - return hash("CreateSessionEntityType") - - __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: gcdc_session_entity_type.CreateSessionEntityTypeRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_session_entity_type.SessionEntityType: - r"""Call the create session entity - type method over HTTP. - - Args: - request (~.gcdc_session_entity_type.CreateSessionEntityTypeRequest): - The request object. The request message for - [SessionEntityTypes.CreateSessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityTypes.CreateSessionEntityType]. - 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: - ~.gcdc_session_entity_type.SessionEntityType: - Session entity types are referred to as **User** entity - types and are entities that are built for an individual - user such as favorites, preferences, playlists, and so - on. - - You can redefine a session entity type at the session - level to extend or replace a [custom entity - type][google.cloud.dialogflow.cx.v3.EntityType] at the - user session level (we refer to the entity types defined - at the agent level as "custom entity types"). - - Note: session entity types apply to all queries, - regardless of the language. - - For more information about entity types, see the - `Dialogflow - documentation `__. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*/sessions/*}/entityTypes', - 'body': 'session_entity_type', - }, -{ - 'method': 'post', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*/environments/*/sessions/*}/entityTypes', - 'body': 'session_entity_type', - }, - ] - request, metadata = self._interceptor.pre_create_session_entity_type(request, metadata) - pb_request = gcdc_session_entity_type.CreateSessionEntityTypeRequest.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 = gcdc_session_entity_type.SessionEntityType() - pb_resp = gcdc_session_entity_type.SessionEntityType.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_session_entity_type(resp) - return resp - - class _DeleteSessionEntityType(SessionEntityTypesRestStub): - def __hash__(self): - return hash("DeleteSessionEntityType") - - __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: session_entity_type.DeleteSessionEntityTypeRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete session entity - type method over HTTP. - - Args: - request (~.session_entity_type.DeleteSessionEntityTypeRequest): - The request object. The request message for - [SessionEntityTypes.DeleteSessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityTypes.DeleteSessionEntityType]. - 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': '/v3/{name=projects/*/locations/*/agents/*/sessions/*/entityTypes/*}', - }, -{ - 'method': 'delete', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/environments/*/sessions/*/entityTypes/*}', - }, - ] - request, metadata = self._interceptor.pre_delete_session_entity_type(request, metadata) - pb_request = session_entity_type.DeleteSessionEntityTypeRequest.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 _GetSessionEntityType(SessionEntityTypesRestStub): - def __hash__(self): - return hash("GetSessionEntityType") - - __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: session_entity_type.GetSessionEntityTypeRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> session_entity_type.SessionEntityType: - r"""Call the get session entity type method over HTTP. - - Args: - request (~.session_entity_type.GetSessionEntityTypeRequest): - The request object. The request message for - [SessionEntityTypes.GetSessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityTypes.GetSessionEntityType]. - 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: - ~.session_entity_type.SessionEntityType: - Session entity types are referred to as **User** entity - types and are entities that are built for an individual - user such as favorites, preferences, playlists, and so - on. - - You can redefine a session entity type at the session - level to extend or replace a [custom entity - type][google.cloud.dialogflow.cx.v3.EntityType] at the - user session level (we refer to the entity types defined - at the agent level as "custom entity types"). - - Note: session entity types apply to all queries, - regardless of the language. - - For more information about entity types, see the - `Dialogflow - documentation `__. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/sessions/*/entityTypes/*}', - }, -{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/environments/*/sessions/*/entityTypes/*}', - }, - ] - request, metadata = self._interceptor.pre_get_session_entity_type(request, metadata) - pb_request = session_entity_type.GetSessionEntityTypeRequest.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 = session_entity_type.SessionEntityType() - pb_resp = session_entity_type.SessionEntityType.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_session_entity_type(resp) - return resp - - class _ListSessionEntityTypes(SessionEntityTypesRestStub): - def __hash__(self): - return hash("ListSessionEntityTypes") - - __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: session_entity_type.ListSessionEntityTypesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> session_entity_type.ListSessionEntityTypesResponse: - r"""Call the list session entity types method over HTTP. - - Args: - request (~.session_entity_type.ListSessionEntityTypesRequest): - The request object. The request message for - [SessionEntityTypes.ListSessionEntityTypes][google.cloud.dialogflow.cx.v3.SessionEntityTypes.ListSessionEntityTypes]. - 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: - ~.session_entity_type.ListSessionEntityTypesResponse: - The response message for - [SessionEntityTypes.ListSessionEntityTypes][google.cloud.dialogflow.cx.v3.SessionEntityTypes.ListSessionEntityTypes]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*/sessions/*}/entityTypes', - }, -{ - 'method': 'get', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*/environments/*/sessions/*}/entityTypes', - }, - ] - request, metadata = self._interceptor.pre_list_session_entity_types(request, metadata) - pb_request = session_entity_type.ListSessionEntityTypesRequest.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 = session_entity_type.ListSessionEntityTypesResponse() - pb_resp = session_entity_type.ListSessionEntityTypesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_session_entity_types(resp) - return resp - - class _UpdateSessionEntityType(SessionEntityTypesRestStub): - def __hash__(self): - return hash("UpdateSessionEntityType") - - __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: gcdc_session_entity_type.UpdateSessionEntityTypeRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_session_entity_type.SessionEntityType: - r"""Call the update session entity - type method over HTTP. - - Args: - request (~.gcdc_session_entity_type.UpdateSessionEntityTypeRequest): - The request object. The request message for - [SessionEntityTypes.UpdateSessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityTypes.UpdateSessionEntityType]. - 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: - ~.gcdc_session_entity_type.SessionEntityType: - Session entity types are referred to as **User** entity - types and are entities that are built for an individual - user such as favorites, preferences, playlists, and so - on. - - You can redefine a session entity type at the session - level to extend or replace a [custom entity - type][google.cloud.dialogflow.cx.v3.EntityType] at the - user session level (we refer to the entity types defined - at the agent level as "custom entity types"). - - Note: session entity types apply to all queries, - regardless of the language. - - For more information about entity types, see the - `Dialogflow - documentation `__. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v3/{session_entity_type.name=projects/*/locations/*/agents/*/sessions/*/entityTypes/*}', - 'body': 'session_entity_type', - }, -{ - 'method': 'patch', - 'uri': '/v3/{session_entity_type.name=projects/*/locations/*/agents/*/environments/*/sessions/*/entityTypes/*}', - 'body': 'session_entity_type', - }, - ] - request, metadata = self._interceptor.pre_update_session_entity_type(request, metadata) - pb_request = gcdc_session_entity_type.UpdateSessionEntityTypeRequest.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 = gcdc_session_entity_type.SessionEntityType() - pb_resp = gcdc_session_entity_type.SessionEntityType.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_session_entity_type(resp) - return resp - - @property - def create_session_entity_type(self) -> Callable[ - [gcdc_session_entity_type.CreateSessionEntityTypeRequest], - gcdc_session_entity_type.SessionEntityType]: - # 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._CreateSessionEntityType(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_session_entity_type(self) -> Callable[ - [session_entity_type.DeleteSessionEntityTypeRequest], - 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._DeleteSessionEntityType(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_session_entity_type(self) -> Callable[ - [session_entity_type.GetSessionEntityTypeRequest], - session_entity_type.SessionEntityType]: - # 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._GetSessionEntityType(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_session_entity_types(self) -> Callable[ - [session_entity_type.ListSessionEntityTypesRequest], - session_entity_type.ListSessionEntityTypesResponse]: - # 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._ListSessionEntityTypes(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_session_entity_type(self) -> Callable[ - [gcdc_session_entity_type.UpdateSessionEntityTypeRequest], - gcdc_session_entity_type.SessionEntityType]: - # 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._UpdateSessionEntityType(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_location(self): - return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore - - class _GetLocation(SessionEntityTypesRestStub): - def __call__(self, - request: locations_pb2.GetLocationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.Location: - - r"""Call the get location method over HTTP. - - Args: - request (locations_pb2.GetLocationRequest): - The request object for GetLocation 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: - locations_pb2.Location: Response from GetLocation method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*}', - }, - ] - - request, metadata = self._interceptor.pre_get_location(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 = locations_pb2.Location() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_get_location(resp) - return resp - - @property - def list_locations(self): - return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore - - class _ListLocations(SessionEntityTypesRestStub): - def __call__(self, - request: locations_pb2.ListLocationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.ListLocationsResponse: - - r"""Call the list locations method over HTTP. - - Args: - request (locations_pb2.ListLocationsRequest): - The request object for ListLocations 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: - locations_pb2.ListLocationsResponse: Response from ListLocations method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*}/locations', - }, - ] - - request, metadata = self._interceptor.pre_list_locations(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 = locations_pb2.ListLocationsResponse() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_list_locations(resp) - return resp - - @property - def cancel_operation(self): - return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore - - class _CancelOperation(SessionEntityTypesRestStub): - 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': '/v3/{name=projects/*/operations/*}:cancel', - }, -{ - 'method': 'post', - 'uri': '/v3/{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(SessionEntityTypesRestStub): - 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': '/v3/{name=projects/*/operations/*}', - }, -{ - 'method': 'get', - 'uri': '/v3/{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(SessionEntityTypesRestStub): - 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': '/v3/{name=projects/*}/operations', - }, -{ - 'method': 'get', - 'uri': '/v3/{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__=( - 'SessionEntityTypesRestTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/__init__.py deleted file mode 100644 index 9b995677..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/__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 SessionsClient -from .async_client import SessionsAsyncClient - -__all__ = ( - 'SessionsClient', - 'SessionsAsyncClient', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/async_client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/async_client.py deleted file mode 100644 index 249106f3..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/async_client.py +++ /dev/null @@ -1,899 +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, AsyncIterable, Awaitable, AsyncIterator, Sequence, Tuple, Type, Union - -from google.cloud.dialogflowcx_v3 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.cloud.dialogflowcx_v3.types import audio_config -from google.cloud.dialogflowcx_v3.types import page -from google.cloud.dialogflowcx_v3.types import session -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from .transports.base import SessionsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import SessionsGrpcAsyncIOTransport -from .client import SessionsClient - - -class SessionsAsyncClient: - """A session represents an interaction with a user. You retrieve user - input and pass it to the - [DetectIntent][google.cloud.dialogflow.cx.v3.Sessions.DetectIntent] - method to determine user intent and respond. - """ - - _client: SessionsClient - - DEFAULT_ENDPOINT = SessionsClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = SessionsClient.DEFAULT_MTLS_ENDPOINT - - entity_type_path = staticmethod(SessionsClient.entity_type_path) - parse_entity_type_path = staticmethod(SessionsClient.parse_entity_type_path) - flow_path = staticmethod(SessionsClient.flow_path) - parse_flow_path = staticmethod(SessionsClient.parse_flow_path) - intent_path = staticmethod(SessionsClient.intent_path) - parse_intent_path = staticmethod(SessionsClient.parse_intent_path) - page_path = staticmethod(SessionsClient.page_path) - parse_page_path = staticmethod(SessionsClient.parse_page_path) - session_path = staticmethod(SessionsClient.session_path) - parse_session_path = staticmethod(SessionsClient.parse_session_path) - session_entity_type_path = staticmethod(SessionsClient.session_entity_type_path) - parse_session_entity_type_path = staticmethod(SessionsClient.parse_session_entity_type_path) - transition_route_group_path = staticmethod(SessionsClient.transition_route_group_path) - parse_transition_route_group_path = staticmethod(SessionsClient.parse_transition_route_group_path) - version_path = staticmethod(SessionsClient.version_path) - parse_version_path = staticmethod(SessionsClient.parse_version_path) - webhook_path = staticmethod(SessionsClient.webhook_path) - parse_webhook_path = staticmethod(SessionsClient.parse_webhook_path) - common_billing_account_path = staticmethod(SessionsClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(SessionsClient.parse_common_billing_account_path) - common_folder_path = staticmethod(SessionsClient.common_folder_path) - parse_common_folder_path = staticmethod(SessionsClient.parse_common_folder_path) - common_organization_path = staticmethod(SessionsClient.common_organization_path) - parse_common_organization_path = staticmethod(SessionsClient.parse_common_organization_path) - common_project_path = staticmethod(SessionsClient.common_project_path) - parse_common_project_path = staticmethod(SessionsClient.parse_common_project_path) - common_location_path = staticmethod(SessionsClient.common_location_path) - parse_common_location_path = staticmethod(SessionsClient.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: - SessionsAsyncClient: The constructed client. - """ - return SessionsClient.from_service_account_info.__func__(SessionsAsyncClient, 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: - SessionsAsyncClient: The constructed client. - """ - return SessionsClient.from_service_account_file.__func__(SessionsAsyncClient, 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 SessionsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> SessionsTransport: - """Returns the transport used by the client instance. - - Returns: - SessionsTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(SessionsClient).get_transport_class, type(SessionsClient)) - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, SessionsTransport] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the sessions 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, ~.SessionsTransport]): 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 = SessionsClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def detect_intent(self, - request: Optional[Union[session.DetectIntentRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> session.DetectIntentResponse: - r"""Processes a natural language query and returns structured, - actionable data as a result. This method is not idempotent, - because it may cause session entity types to be updated, which - in turn might affect results of future queries. - - Note: Always use agent versions for production traffic. See - `Versions and - environments `__. - - .. 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 dialogflowcx_v3 - - async def sample_detect_intent(): - # Create a client - client = dialogflowcx_v3.SessionsAsyncClient() - - # Initialize request argument(s) - query_input = dialogflowcx_v3.QueryInput() - query_input.text.text = "text_value" - query_input.language_code = "language_code_value" - - request = dialogflowcx_v3.DetectIntentRequest( - session="session_value", - query_input=query_input, - ) - - # Make the request - response = await client.detect_intent(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.DetectIntentRequest, dict]]): - The request object. The request to detect user's intent. - 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.dialogflowcx_v3.types.DetectIntentResponse: - The message returned from the - DetectIntent method. - - """ - # Create or coerce a protobuf request object. - request = session.DetectIntentRequest(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.detect_intent, - default_retry=retries.Retry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=220.0, - ), - default_timeout=220.0, - 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(( - ("session", request.session), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def streaming_detect_intent(self, - requests: Optional[AsyncIterator[session.StreamingDetectIntentRequest]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> Awaitable[AsyncIterable[session.StreamingDetectIntentResponse]]: - r"""Processes a natural language query in audio format in a - streaming fashion and returns structured, actionable data as a - result. This method is only available via the gRPC API (not - REST). - - Note: Always use agent versions for production traffic. See - `Versions and - environments `__. - - .. 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 dialogflowcx_v3 - - async def sample_streaming_detect_intent(): - # Create a client - client = dialogflowcx_v3.SessionsAsyncClient() - - # Initialize request argument(s) - query_input = dialogflowcx_v3.QueryInput() - query_input.text.text = "text_value" - query_input.language_code = "language_code_value" - - request = dialogflowcx_v3.StreamingDetectIntentRequest( - query_input=query_input, - ) - - # This method expects an iterator which contains - # 'dialogflowcx_v3.StreamingDetectIntentRequest' objects - # Here we create a generator that yields a single `request` for - # demonstrative purposes. - requests = [request] - - def request_generator(): - for request in requests: - yield request - - # Make the request - stream = await client.streaming_detect_intent(requests=request_generator()) - - # Handle the response - async for response in stream: - print(response) - - Args: - requests (AsyncIterator[`google.cloud.dialogflowcx_v3.types.StreamingDetectIntentRequest`]): - The request object AsyncIterator. The top-level message sent by the client to the - [Sessions.StreamingDetectIntent][google.cloud.dialogflow.cx.v3.Sessions.StreamingDetectIntent] - method. - - Multiple request messages should be sent in order: - - 1. The first message must contain - [session][google.cloud.dialogflow.cx.v3.StreamingDetectIntentRequest.session], - [query_input][google.cloud.dialogflow.cx.v3.StreamingDetectIntentRequest.query_input] - plus optionally - [query_params][google.cloud.dialogflow.cx.v3.StreamingDetectIntentRequest.query_params]. - If the client wants to receive an audio response, it - should also contain - [output_audio_config][google.cloud.dialogflow.cx.v3.StreamingDetectIntentRequest.output_audio_config]. - - 2. If - [query_input][google.cloud.dialogflow.cx.v3.StreamingDetectIntentRequest.query_input] - was set to - [query_input.audio.config][google.cloud.dialogflow.cx.v3.AudioInput.config], - all subsequent messages must contain - [query_input.audio.audio][google.cloud.dialogflow.cx.v3.AudioInput.audio] - to continue with Speech recognition. If you decide to - rather detect an intent from text input after you - already started Speech recognition, please send a - message with - [query_input.text][google.cloud.dialogflow.cx.v3.QueryInput.text]. - - However, note that: - - - Dialogflow will bill you for the audio duration so - far. - - Dialogflow discards all Speech recognition results - in favor of the input text. - - Dialogflow will use the language code from the - first message. - - After you sent all input, you must half-close or abort - the request stream. - 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: - AsyncIterable[google.cloud.dialogflowcx_v3.types.StreamingDetectIntentResponse]: - The top-level message returned from the - [StreamingDetectIntent][google.cloud.dialogflow.cx.v3.Sessions.StreamingDetectIntent] - method. - - Multiple response messages (N) can be returned in - order. - - The first (N-1) responses set either the - recognition_result or detect_intent_response field, - depending on the request: - - - If the - StreamingDetectIntentRequest.query_input.audio - field was set, and the - StreamingDetectIntentRequest.enable_partial_response - field was false, the recognition_result field is - populated for each of the (N-1) responses. See the - [StreamingRecognitionResult][google.cloud.dialogflow.cx.v3.StreamingRecognitionResult] - message for details about the result message - sequence. - - If the - StreamingDetectIntentRequest.enable_partial_response - field was true, the detect_intent_response field - is populated for each of the (N-1) responses, - where 1 <= N <= 4. These responses set the - [DetectIntentResponse.response_type][google.cloud.dialogflow.cx.v3.DetectIntentResponse.response_type] - field to PARTIAL. - - For the final Nth response message, the - detect_intent_response is fully populated, and - [DetectIntentResponse.response_type][google.cloud.dialogflow.cx.v3.DetectIntentResponse.response_type] - is set to FINAL. - - """ - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.streaming_detect_intent, - default_timeout=220.0, - client_info=DEFAULT_CLIENT_INFO, - ) - - # Send the request. - response = rpc( - requests, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def match_intent(self, - request: Optional[Union[session.MatchIntentRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> session.MatchIntentResponse: - r"""Returns preliminary intent match results, doesn't - change the session status. - - .. 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 dialogflowcx_v3 - - async def sample_match_intent(): - # Create a client - client = dialogflowcx_v3.SessionsAsyncClient() - - # Initialize request argument(s) - query_input = dialogflowcx_v3.QueryInput() - query_input.text.text = "text_value" - query_input.language_code = "language_code_value" - - request = dialogflowcx_v3.MatchIntentRequest( - session="session_value", - query_input=query_input, - ) - - # Make the request - response = await client.match_intent(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.MatchIntentRequest, dict]]): - The request object. Request of [MatchIntent][]. - 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.dialogflowcx_v3.types.MatchIntentResponse: - Response of [MatchIntent][]. - """ - # Create or coerce a protobuf request object. - request = session.MatchIntentRequest(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.match_intent, - 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(( - ("session", request.session), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def fulfill_intent(self, - request: Optional[Union[session.FulfillIntentRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> session.FulfillIntentResponse: - r"""Fulfills a matched intent returned by - [MatchIntent][google.cloud.dialogflow.cx.v3.Sessions.MatchIntent]. - Must be called after - [MatchIntent][google.cloud.dialogflow.cx.v3.Sessions.MatchIntent], - with input from - [MatchIntentResponse][google.cloud.dialogflow.cx.v3.MatchIntentResponse]. - Otherwise, the behavior is undefined. - - .. 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 dialogflowcx_v3 - - async def sample_fulfill_intent(): - # Create a client - client = dialogflowcx_v3.SessionsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.FulfillIntentRequest( - ) - - # Make the request - response = await client.fulfill_intent(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.FulfillIntentRequest, dict]]): - The request object. Request of [FulfillIntent][] - 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.dialogflowcx_v3.types.FulfillIntentResponse: - Response of [FulfillIntent][] - """ - # Create or coerce a protobuf request object. - request = session.FulfillIntentRequest(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.fulfill_intent, - 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(( - ("match_intent_request.session", request.match_intent_request.session), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - 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 get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**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_location, - 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_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**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_locations, - 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 __aenter__(self) -> "SessionsAsyncClient": - 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__ = ( - "SessionsAsyncClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/client.py deleted file mode 100644 index c9547ccd..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/client.py +++ /dev/null @@ -1,1163 +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, Iterable, Iterator, Sequence, Tuple, Type, Union, cast - -from google.cloud.dialogflowcx_v3 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.cloud.dialogflowcx_v3.types import audio_config -from google.cloud.dialogflowcx_v3.types import page -from google.cloud.dialogflowcx_v3.types import session -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from .transports.base import SessionsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import SessionsGrpcTransport -from .transports.grpc_asyncio import SessionsGrpcAsyncIOTransport -from .transports.rest import SessionsRestTransport - - -class SessionsClientMeta(type): - """Metaclass for the Sessions 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[SessionsTransport]] - _transport_registry["grpc"] = SessionsGrpcTransport - _transport_registry["grpc_asyncio"] = SessionsGrpcAsyncIOTransport - _transport_registry["rest"] = SessionsRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[SessionsTransport]: - """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 SessionsClient(metaclass=SessionsClientMeta): - """A session represents an interaction with a user. You retrieve user - input and pass it to the - [DetectIntent][google.cloud.dialogflow.cx.v3.Sessions.DetectIntent] - method to determine user intent and respond. - """ - - @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 = "dialogflow.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: - SessionsClient: 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: - SessionsClient: 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) -> SessionsTransport: - """Returns the transport used by the client instance. - - Returns: - SessionsTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def entity_type_path(project: str,location: str,agent: str,entity_type: str,) -> str: - """Returns a fully-qualified entity_type string.""" - return "projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type}".format(project=project, location=location, agent=agent, entity_type=entity_type, ) - - @staticmethod - def parse_entity_type_path(path: str) -> Dict[str,str]: - """Parses a entity_type path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/entityTypes/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def flow_path(project: str,location: str,agent: str,flow: str,) -> str: - """Returns a fully-qualified flow string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}".format(project=project, location=location, agent=agent, flow=flow, ) - - @staticmethod - def parse_flow_path(path: str) -> Dict[str,str]: - """Parses a flow path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def intent_path(project: str,location: str,agent: str,intent: str,) -> str: - """Returns a fully-qualified intent string.""" - return "projects/{project}/locations/{location}/agents/{agent}/intents/{intent}".format(project=project, location=location, agent=agent, intent=intent, ) - - @staticmethod - def parse_intent_path(path: str) -> Dict[str,str]: - """Parses a intent path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/intents/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def page_path(project: str,location: str,agent: str,flow: str,page: str,) -> str: - """Returns a fully-qualified page string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page}".format(project=project, location=location, agent=agent, flow=flow, page=page, ) - - @staticmethod - def parse_page_path(path: str) -> Dict[str,str]: - """Parses a page path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)/pages/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def session_path(project: str,location: str,agent: str,session: str,) -> str: - """Returns a fully-qualified session string.""" - return "projects/{project}/locations/{location}/agents/{agent}/sessions/{session}".format(project=project, location=location, agent=agent, session=session, ) - - @staticmethod - def parse_session_path(path: str) -> Dict[str,str]: - """Parses a session path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/sessions/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def session_entity_type_path(project: str,location: str,agent: str,session: str,entity_type: str,) -> str: - """Returns a fully-qualified session_entity_type string.""" - return "projects/{project}/locations/{location}/agents/{agent}/sessions/{session}/entityTypes/{entity_type}".format(project=project, location=location, agent=agent, session=session, entity_type=entity_type, ) - - @staticmethod - def parse_session_entity_type_path(path: str) -> Dict[str,str]: - """Parses a session_entity_type path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/sessions/(?P.+?)/entityTypes/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def transition_route_group_path(project: str,location: str,agent: str,flow: str,transition_route_group: str,) -> str: - """Returns a fully-qualified transition_route_group string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}".format(project=project, location=location, agent=agent, flow=flow, transition_route_group=transition_route_group, ) - - @staticmethod - def parse_transition_route_group_path(path: str) -> Dict[str,str]: - """Parses a transition_route_group path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)/transitionRouteGroups/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def version_path(project: str,location: str,agent: str,flow: str,version: str,) -> str: - """Returns a fully-qualified version string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version}".format(project=project, location=location, agent=agent, flow=flow, version=version, ) - - @staticmethod - def parse_version_path(path: str) -> Dict[str,str]: - """Parses a version path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)/versions/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def webhook_path(project: str,location: str,agent: str,webhook: str,) -> str: - """Returns a fully-qualified webhook string.""" - return "projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}".format(project=project, location=location, agent=agent, webhook=webhook, ) - - @staticmethod - def parse_webhook_path(path: str) -> Dict[str,str]: - """Parses a webhook path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/webhooks/(?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, SessionsTransport]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the sessions 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, SessionsTransport]): 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, SessionsTransport): - # transport is a SessionsTransport 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 detect_intent(self, - request: Optional[Union[session.DetectIntentRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> session.DetectIntentResponse: - r"""Processes a natural language query and returns structured, - actionable data as a result. This method is not idempotent, - because it may cause session entity types to be updated, which - in turn might affect results of future queries. - - Note: Always use agent versions for production traffic. See - `Versions and - environments `__. - - .. 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 dialogflowcx_v3 - - def sample_detect_intent(): - # Create a client - client = dialogflowcx_v3.SessionsClient() - - # Initialize request argument(s) - query_input = dialogflowcx_v3.QueryInput() - query_input.text.text = "text_value" - query_input.language_code = "language_code_value" - - request = dialogflowcx_v3.DetectIntentRequest( - session="session_value", - query_input=query_input, - ) - - # Make the request - response = client.detect_intent(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.DetectIntentRequest, dict]): - The request object. The request to detect user's intent. - 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.dialogflowcx_v3.types.DetectIntentResponse: - The message returned from the - DetectIntent method. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a session.DetectIntentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, session.DetectIntentRequest): - request = session.DetectIntentRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.detect_intent] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("session", request.session), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def streaming_detect_intent(self, - requests: Optional[Iterator[session.StreamingDetectIntentRequest]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> Iterable[session.StreamingDetectIntentResponse]: - r"""Processes a natural language query in audio format in a - streaming fashion and returns structured, actionable data as a - result. This method is only available via the gRPC API (not - REST). - - Note: Always use agent versions for production traffic. See - `Versions and - environments `__. - - .. 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 dialogflowcx_v3 - - def sample_streaming_detect_intent(): - # Create a client - client = dialogflowcx_v3.SessionsClient() - - # Initialize request argument(s) - query_input = dialogflowcx_v3.QueryInput() - query_input.text.text = "text_value" - query_input.language_code = "language_code_value" - - request = dialogflowcx_v3.StreamingDetectIntentRequest( - query_input=query_input, - ) - - # This method expects an iterator which contains - # 'dialogflowcx_v3.StreamingDetectIntentRequest' objects - # Here we create a generator that yields a single `request` for - # demonstrative purposes. - requests = [request] - - def request_generator(): - for request in requests: - yield request - - # Make the request - stream = client.streaming_detect_intent(requests=request_generator()) - - # Handle the response - for response in stream: - print(response) - - Args: - requests (Iterator[google.cloud.dialogflowcx_v3.types.StreamingDetectIntentRequest]): - The request object iterator. The top-level message sent by the client to the - [Sessions.StreamingDetectIntent][google.cloud.dialogflow.cx.v3.Sessions.StreamingDetectIntent] - method. - - Multiple request messages should be sent in order: - - 1. The first message must contain - [session][google.cloud.dialogflow.cx.v3.StreamingDetectIntentRequest.session], - [query_input][google.cloud.dialogflow.cx.v3.StreamingDetectIntentRequest.query_input] - plus optionally - [query_params][google.cloud.dialogflow.cx.v3.StreamingDetectIntentRequest.query_params]. - If the client wants to receive an audio response, it - should also contain - [output_audio_config][google.cloud.dialogflow.cx.v3.StreamingDetectIntentRequest.output_audio_config]. - - 2. If - [query_input][google.cloud.dialogflow.cx.v3.StreamingDetectIntentRequest.query_input] - was set to - [query_input.audio.config][google.cloud.dialogflow.cx.v3.AudioInput.config], - all subsequent messages must contain - [query_input.audio.audio][google.cloud.dialogflow.cx.v3.AudioInput.audio] - to continue with Speech recognition. If you decide to - rather detect an intent from text input after you - already started Speech recognition, please send a - message with - [query_input.text][google.cloud.dialogflow.cx.v3.QueryInput.text]. - - However, note that: - - - Dialogflow will bill you for the audio duration so - far. - - Dialogflow discards all Speech recognition results - in favor of the input text. - - Dialogflow will use the language code from the - first message. - - After you sent all input, you must half-close or abort - the request stream. - 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: - Iterable[google.cloud.dialogflowcx_v3.types.StreamingDetectIntentResponse]: - The top-level message returned from the - [StreamingDetectIntent][google.cloud.dialogflow.cx.v3.Sessions.StreamingDetectIntent] - method. - - Multiple response messages (N) can be returned in - order. - - The first (N-1) responses set either the - recognition_result or detect_intent_response field, - depending on the request: - - - If the - StreamingDetectIntentRequest.query_input.audio - field was set, and the - StreamingDetectIntentRequest.enable_partial_response - field was false, the recognition_result field is - populated for each of the (N-1) responses. See the - [StreamingRecognitionResult][google.cloud.dialogflow.cx.v3.StreamingRecognitionResult] - message for details about the result message - sequence. - - If the - StreamingDetectIntentRequest.enable_partial_response - field was true, the detect_intent_response field - is populated for each of the (N-1) responses, - where 1 <= N <= 4. These responses set the - [DetectIntentResponse.response_type][google.cloud.dialogflow.cx.v3.DetectIntentResponse.response_type] - field to PARTIAL. - - For the final Nth response message, the - detect_intent_response is fully populated, and - [DetectIntentResponse.response_type][google.cloud.dialogflow.cx.v3.DetectIntentResponse.response_type] - is set to FINAL. - - """ - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.streaming_detect_intent] - - # Send the request. - response = rpc( - requests, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def match_intent(self, - request: Optional[Union[session.MatchIntentRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> session.MatchIntentResponse: - r"""Returns preliminary intent match results, doesn't - change the session status. - - .. 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 dialogflowcx_v3 - - def sample_match_intent(): - # Create a client - client = dialogflowcx_v3.SessionsClient() - - # Initialize request argument(s) - query_input = dialogflowcx_v3.QueryInput() - query_input.text.text = "text_value" - query_input.language_code = "language_code_value" - - request = dialogflowcx_v3.MatchIntentRequest( - session="session_value", - query_input=query_input, - ) - - # Make the request - response = client.match_intent(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.MatchIntentRequest, dict]): - The request object. Request of [MatchIntent][]. - 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.dialogflowcx_v3.types.MatchIntentResponse: - Response of [MatchIntent][]. - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a session.MatchIntentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, session.MatchIntentRequest): - request = session.MatchIntentRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.match_intent] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("session", request.session), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def fulfill_intent(self, - request: Optional[Union[session.FulfillIntentRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> session.FulfillIntentResponse: - r"""Fulfills a matched intent returned by - [MatchIntent][google.cloud.dialogflow.cx.v3.Sessions.MatchIntent]. - Must be called after - [MatchIntent][google.cloud.dialogflow.cx.v3.Sessions.MatchIntent], - with input from - [MatchIntentResponse][google.cloud.dialogflow.cx.v3.MatchIntentResponse]. - Otherwise, the behavior is undefined. - - .. 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 dialogflowcx_v3 - - def sample_fulfill_intent(): - # Create a client - client = dialogflowcx_v3.SessionsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.FulfillIntentRequest( - ) - - # Make the request - response = client.fulfill_intent(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.FulfillIntentRequest, dict]): - The request object. Request of [FulfillIntent][] - 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.dialogflowcx_v3.types.FulfillIntentResponse: - Response of [FulfillIntent][] - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a session.FulfillIntentRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, session.FulfillIntentRequest): - request = session.FulfillIntentRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.fulfill_intent] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("match_intent_request.session", request.match_intent_request.session), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def __enter__(self) -> "SessionsClient": - 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,) - - def get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.get_location, - 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 list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.list_locations, - 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 - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "SessionsClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/transports/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/transports/__init__.py deleted file mode 100644 index 6356da4d..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/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 SessionsTransport -from .grpc import SessionsGrpcTransport -from .grpc_asyncio import SessionsGrpcAsyncIOTransport -from .rest import SessionsRestTransport -from .rest import SessionsRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[SessionsTransport]] -_transport_registry['grpc'] = SessionsGrpcTransport -_transport_registry['grpc_asyncio'] = SessionsGrpcAsyncIOTransport -_transport_registry['rest'] = SessionsRestTransport - -__all__ = ( - 'SessionsTransport', - 'SessionsGrpcTransport', - 'SessionsGrpcAsyncIOTransport', - 'SessionsRestTransport', - 'SessionsRestInterceptor', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/transports/base.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/transports/base.py deleted file mode 100644 index 633b316e..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/transports/base.py +++ /dev/null @@ -1,242 +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.dialogflowcx_v3 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.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.dialogflowcx_v3.types import session -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -class SessionsTransport(abc.ABC): - """Abstract transport class for Sessions.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/dialogflow', - ) - - DEFAULT_HOST: str = 'dialogflow.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.detect_intent: gapic_v1.method.wrap_method( - self.detect_intent, - default_retry=retries.Retry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=220.0, - ), - default_timeout=220.0, - client_info=client_info, - ), - self.streaming_detect_intent: gapic_v1.method.wrap_method( - self.streaming_detect_intent, - default_timeout=220.0, - client_info=client_info, - ), - self.match_intent: gapic_v1.method.wrap_method( - self.match_intent, - default_timeout=None, - client_info=client_info, - ), - self.fulfill_intent: gapic_v1.method.wrap_method( - self.fulfill_intent, - 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 detect_intent(self) -> Callable[ - [session.DetectIntentRequest], - Union[ - session.DetectIntentResponse, - Awaitable[session.DetectIntentResponse] - ]]: - raise NotImplementedError() - - @property - def streaming_detect_intent(self) -> Callable[ - [session.StreamingDetectIntentRequest], - Union[ - session.StreamingDetectIntentResponse, - Awaitable[session.StreamingDetectIntentResponse] - ]]: - raise NotImplementedError() - - @property - def match_intent(self) -> Callable[ - [session.MatchIntentRequest], - Union[ - session.MatchIntentResponse, - Awaitable[session.MatchIntentResponse] - ]]: - raise NotImplementedError() - - @property - def fulfill_intent(self) -> Callable[ - [session.FulfillIntentRequest], - Union[ - session.FulfillIntentResponse, - Awaitable[session.FulfillIntentResponse] - ]]: - 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 get_location(self, - ) -> Callable[ - [locations_pb2.GetLocationRequest], - Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], - ]: - raise NotImplementedError() - - @property - def list_locations(self, - ) -> Callable[ - [locations_pb2.ListLocationsRequest], - Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'SessionsTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc.py deleted file mode 100644 index 43792805..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc.py +++ /dev/null @@ -1,458 +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 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.dialogflowcx_v3.types import session -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from .base import SessionsTransport, DEFAULT_CLIENT_INFO - - -class SessionsGrpcTransport(SessionsTransport): - """gRPC backend transport for Sessions. - - A session represents an interaction with a user. You retrieve user - input and pass it to the - [DetectIntent][google.cloud.dialogflow.cx.v3.Sessions.DetectIntent] - method to determine user intent and respond. - - 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 = 'dialogflow.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] = {} - - 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 = 'dialogflow.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 detect_intent(self) -> Callable[ - [session.DetectIntentRequest], - session.DetectIntentResponse]: - r"""Return a callable for the detect intent method over gRPC. - - Processes a natural language query and returns structured, - actionable data as a result. This method is not idempotent, - because it may cause session entity types to be updated, which - in turn might affect results of future queries. - - Note: Always use agent versions for production traffic. See - `Versions and - environments `__. - - Returns: - Callable[[~.DetectIntentRequest], - ~.DetectIntentResponse]: - 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 'detect_intent' not in self._stubs: - self._stubs['detect_intent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Sessions/DetectIntent', - request_serializer=session.DetectIntentRequest.serialize, - response_deserializer=session.DetectIntentResponse.deserialize, - ) - return self._stubs['detect_intent'] - - @property - def streaming_detect_intent(self) -> Callable[ - [session.StreamingDetectIntentRequest], - session.StreamingDetectIntentResponse]: - r"""Return a callable for the streaming detect intent method over gRPC. - - Processes a natural language query in audio format in a - streaming fashion and returns structured, actionable data as a - result. This method is only available via the gRPC API (not - REST). - - Note: Always use agent versions for production traffic. See - `Versions and - environments `__. - - Returns: - Callable[[~.StreamingDetectIntentRequest], - ~.StreamingDetectIntentResponse]: - 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 'streaming_detect_intent' not in self._stubs: - self._stubs['streaming_detect_intent'] = self.grpc_channel.stream_stream( - '/google.cloud.dialogflow.cx.v3.Sessions/StreamingDetectIntent', - request_serializer=session.StreamingDetectIntentRequest.serialize, - response_deserializer=session.StreamingDetectIntentResponse.deserialize, - ) - return self._stubs['streaming_detect_intent'] - - @property - def match_intent(self) -> Callable[ - [session.MatchIntentRequest], - session.MatchIntentResponse]: - r"""Return a callable for the match intent method over gRPC. - - Returns preliminary intent match results, doesn't - change the session status. - - Returns: - Callable[[~.MatchIntentRequest], - ~.MatchIntentResponse]: - 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 'match_intent' not in self._stubs: - self._stubs['match_intent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Sessions/MatchIntent', - request_serializer=session.MatchIntentRequest.serialize, - response_deserializer=session.MatchIntentResponse.deserialize, - ) - return self._stubs['match_intent'] - - @property - def fulfill_intent(self) -> Callable[ - [session.FulfillIntentRequest], - session.FulfillIntentResponse]: - r"""Return a callable for the fulfill intent method over gRPC. - - Fulfills a matched intent returned by - [MatchIntent][google.cloud.dialogflow.cx.v3.Sessions.MatchIntent]. - Must be called after - [MatchIntent][google.cloud.dialogflow.cx.v3.Sessions.MatchIntent], - with input from - [MatchIntentResponse][google.cloud.dialogflow.cx.v3.MatchIntentResponse]. - Otherwise, the behavior is undefined. - - Returns: - Callable[[~.FulfillIntentRequest], - ~.FulfillIntentResponse]: - 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 'fulfill_intent' not in self._stubs: - self._stubs['fulfill_intent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Sessions/FulfillIntent', - request_serializer=session.FulfillIntentRequest.serialize, - response_deserializer=session.FulfillIntentResponse.deserialize, - ) - return self._stubs['fulfill_intent'] - - 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 list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'SessionsGrpcTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc_asyncio.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc_asyncio.py deleted file mode 100644 index b68c7117..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc_asyncio.py +++ /dev/null @@ -1,457 +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.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.dialogflowcx_v3.types import session -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from .base import SessionsTransport, DEFAULT_CLIENT_INFO -from .grpc import SessionsGrpcTransport - - -class SessionsGrpcAsyncIOTransport(SessionsTransport): - """gRPC AsyncIO backend transport for Sessions. - - A session represents an interaction with a user. You retrieve user - input and pass it to the - [DetectIntent][google.cloud.dialogflow.cx.v3.Sessions.DetectIntent] - method to determine user intent and respond. - - 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 = 'dialogflow.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 = 'dialogflow.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] = {} - - 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 detect_intent(self) -> Callable[ - [session.DetectIntentRequest], - Awaitable[session.DetectIntentResponse]]: - r"""Return a callable for the detect intent method over gRPC. - - Processes a natural language query and returns structured, - actionable data as a result. This method is not idempotent, - because it may cause session entity types to be updated, which - in turn might affect results of future queries. - - Note: Always use agent versions for production traffic. See - `Versions and - environments `__. - - Returns: - Callable[[~.DetectIntentRequest], - Awaitable[~.DetectIntentResponse]]: - 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 'detect_intent' not in self._stubs: - self._stubs['detect_intent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Sessions/DetectIntent', - request_serializer=session.DetectIntentRequest.serialize, - response_deserializer=session.DetectIntentResponse.deserialize, - ) - return self._stubs['detect_intent'] - - @property - def streaming_detect_intent(self) -> Callable[ - [session.StreamingDetectIntentRequest], - Awaitable[session.StreamingDetectIntentResponse]]: - r"""Return a callable for the streaming detect intent method over gRPC. - - Processes a natural language query in audio format in a - streaming fashion and returns structured, actionable data as a - result. This method is only available via the gRPC API (not - REST). - - Note: Always use agent versions for production traffic. See - `Versions and - environments `__. - - Returns: - Callable[[~.StreamingDetectIntentRequest], - Awaitable[~.StreamingDetectIntentResponse]]: - 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 'streaming_detect_intent' not in self._stubs: - self._stubs['streaming_detect_intent'] = self.grpc_channel.stream_stream( - '/google.cloud.dialogflow.cx.v3.Sessions/StreamingDetectIntent', - request_serializer=session.StreamingDetectIntentRequest.serialize, - response_deserializer=session.StreamingDetectIntentResponse.deserialize, - ) - return self._stubs['streaming_detect_intent'] - - @property - def match_intent(self) -> Callable[ - [session.MatchIntentRequest], - Awaitable[session.MatchIntentResponse]]: - r"""Return a callable for the match intent method over gRPC. - - Returns preliminary intent match results, doesn't - change the session status. - - Returns: - Callable[[~.MatchIntentRequest], - Awaitable[~.MatchIntentResponse]]: - 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 'match_intent' not in self._stubs: - self._stubs['match_intent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Sessions/MatchIntent', - request_serializer=session.MatchIntentRequest.serialize, - response_deserializer=session.MatchIntentResponse.deserialize, - ) - return self._stubs['match_intent'] - - @property - def fulfill_intent(self) -> Callable[ - [session.FulfillIntentRequest], - Awaitable[session.FulfillIntentResponse]]: - r"""Return a callable for the fulfill intent method over gRPC. - - Fulfills a matched intent returned by - [MatchIntent][google.cloud.dialogflow.cx.v3.Sessions.MatchIntent]. - Must be called after - [MatchIntent][google.cloud.dialogflow.cx.v3.Sessions.MatchIntent], - with input from - [MatchIntentResponse][google.cloud.dialogflow.cx.v3.MatchIntentResponse]. - Otherwise, the behavior is undefined. - - Returns: - Callable[[~.FulfillIntentRequest], - Awaitable[~.FulfillIntentResponse]]: - 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 'fulfill_intent' not in self._stubs: - self._stubs['fulfill_intent'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Sessions/FulfillIntent', - request_serializer=session.FulfillIntentRequest.serialize, - response_deserializer=session.FulfillIntentResponse.deserialize, - ) - return self._stubs['fulfill_intent'] - - 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"] - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - -__all__ = ( - 'SessionsGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/transports/rest.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/transports/rest.py deleted file mode 100644 index 3535fa50..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/sessions/transports/rest.py +++ /dev/null @@ -1,1003 +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.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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.dialogflowcx_v3.types import session - -from .base import SessionsTransport, 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 SessionsRestInterceptor: - """Interceptor for Sessions. - - 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 SessionsRestTransport. - - .. code-block:: python - class MyCustomSessionsInterceptor(SessionsRestInterceptor): - def pre_detect_intent(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_detect_intent(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_fulfill_intent(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_fulfill_intent(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_match_intent(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_match_intent(self, response): - logging.log(f"Received response: {response}") - return response - - transport = SessionsRestTransport(interceptor=MyCustomSessionsInterceptor()) - client = SessionsClient(transport=transport) - - - """ - def pre_detect_intent(self, request: session.DetectIntentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[session.DetectIntentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for detect_intent - - Override in a subclass to manipulate the request or metadata - before they are sent to the Sessions server. - """ - return request, metadata - - def post_detect_intent(self, response: session.DetectIntentResponse) -> session.DetectIntentResponse: - """Post-rpc interceptor for detect_intent - - Override in a subclass to manipulate the response - after it is returned by the Sessions server but before - it is returned to user code. - """ - return response - def pre_fulfill_intent(self, request: session.FulfillIntentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[session.FulfillIntentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for fulfill_intent - - Override in a subclass to manipulate the request or metadata - before they are sent to the Sessions server. - """ - return request, metadata - - def post_fulfill_intent(self, response: session.FulfillIntentResponse) -> session.FulfillIntentResponse: - """Post-rpc interceptor for fulfill_intent - - Override in a subclass to manipulate the response - after it is returned by the Sessions server but before - it is returned to user code. - """ - return response - def pre_match_intent(self, request: session.MatchIntentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[session.MatchIntentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for match_intent - - Override in a subclass to manipulate the request or metadata - before they are sent to the Sessions server. - """ - return request, metadata - - def post_match_intent(self, response: session.MatchIntentResponse) -> session.MatchIntentResponse: - """Post-rpc interceptor for match_intent - - Override in a subclass to manipulate the response - after it is returned by the Sessions server but before - it is returned to user code. - """ - return response - - def pre_get_location( - self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_location - - Override in a subclass to manipulate the request or metadata - before they are sent to the Sessions server. - """ - return request, metadata - - def post_get_location( - self, response: locations_pb2.Location - ) -> locations_pb2.Location: - """Post-rpc interceptor for get_location - - Override in a subclass to manipulate the response - after it is returned by the Sessions server but before - it is returned to user code. - """ - return response - def pre_list_locations( - self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_locations - - Override in a subclass to manipulate the request or metadata - before they are sent to the Sessions server. - """ - return request, metadata - - def post_list_locations( - self, response: locations_pb2.ListLocationsResponse - ) -> locations_pb2.ListLocationsResponse: - """Post-rpc interceptor for list_locations - - Override in a subclass to manipulate the response - after it is returned by the Sessions 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 Sessions 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 Sessions 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 Sessions 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 Sessions 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 Sessions 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 Sessions server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class SessionsRestStub: - _session: AuthorizedSession - _host: str - _interceptor: SessionsRestInterceptor - - -class SessionsRestTransport(SessionsTransport): - """REST backend transport for Sessions. - - A session represents an interaction with a user. You retrieve user - input and pass it to the - [DetectIntent][google.cloud.dialogflow.cx.v3.Sessions.DetectIntent] - method to determine user intent and respond. - - 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 = 'dialogflow.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[SessionsRestInterceptor] = 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) - if client_cert_source_for_mtls: - self._session.configure_mtls_channel(client_cert_source_for_mtls) - self._interceptor = interceptor or SessionsRestInterceptor() - self._prep_wrapped_messages(client_info) - - class _DetectIntent(SessionsRestStub): - def __hash__(self): - return hash("DetectIntent") - - __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: session.DetectIntentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> session.DetectIntentResponse: - r"""Call the detect intent method over HTTP. - - Args: - request (~.session.DetectIntentRequest): - The request object. The request to detect user's intent. - 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: - ~.session.DetectIntentResponse: - The message returned from the - DetectIntent method. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v3/{session=projects/*/locations/*/agents/*/sessions/*}:detectIntent', - 'body': '*', - }, -{ - 'method': 'post', - 'uri': '/v3/{session=projects/*/locations/*/agents/*/environments/*/sessions/*}:detectIntent', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_detect_intent(request, metadata) - pb_request = session.DetectIntentRequest.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 = session.DetectIntentResponse() - pb_resp = session.DetectIntentResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_detect_intent(resp) - return resp - - class _FulfillIntent(SessionsRestStub): - def __hash__(self): - return hash("FulfillIntent") - - def __call__(self, - request: session.FulfillIntentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> session.FulfillIntentResponse: - r"""Call the fulfill intent method over HTTP. - - Args: - request (~.session.FulfillIntentRequest): - The request object. Request of [FulfillIntent][] - 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: - ~.session.FulfillIntentResponse: - Response of [FulfillIntent][] - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v3/{match_intent_request.session=projects/*/locations/*/agents/*/sessions/*}:fulfillIntent', - 'body': '*', - }, -{ - 'method': 'post', - 'uri': '/v3/{match_intent_request.session=projects/*/locations/*/agents/*/environments/*/sessions/*}:fulfillIntent', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_fulfill_intent(request, metadata) - pb_request = session.FulfillIntentRequest.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["$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 = session.FulfillIntentResponse() - pb_resp = session.FulfillIntentResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_fulfill_intent(resp) - return resp - - class _MatchIntent(SessionsRestStub): - def __hash__(self): - return hash("MatchIntent") - - __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: session.MatchIntentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> session.MatchIntentResponse: - r"""Call the match intent method over HTTP. - - Args: - request (~.session.MatchIntentRequest): - The request object. Request of [MatchIntent][]. - 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: - ~.session.MatchIntentResponse: - Response of [MatchIntent][]. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v3/{session=projects/*/locations/*/agents/*/sessions/*}:matchIntent', - 'body': '*', - }, -{ - 'method': 'post', - 'uri': '/v3/{session=projects/*/locations/*/agents/*/environments/*/sessions/*}:matchIntent', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_match_intent(request, metadata) - pb_request = session.MatchIntentRequest.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 = session.MatchIntentResponse() - pb_resp = session.MatchIntentResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_match_intent(resp) - return resp - - class _StreamingDetectIntent(SessionsRestStub): - def __hash__(self): - return hash("StreamingDetectIntent") - - def __call__(self, - request: session.StreamingDetectIntentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> rest_streaming.ResponseIterator: - raise NotImplementedError( - "Method StreamingDetectIntent is not available over REST transport" - ) - - @property - def detect_intent(self) -> Callable[ - [session.DetectIntentRequest], - session.DetectIntentResponse]: - # 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._DetectIntent(self._session, self._host, self._interceptor) # type: ignore - - @property - def fulfill_intent(self) -> Callable[ - [session.FulfillIntentRequest], - session.FulfillIntentResponse]: - # 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._FulfillIntent(self._session, self._host, self._interceptor) # type: ignore - - @property - def match_intent(self) -> Callable[ - [session.MatchIntentRequest], - session.MatchIntentResponse]: - # 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._MatchIntent(self._session, self._host, self._interceptor) # type: ignore - - @property - def streaming_detect_intent(self) -> Callable[ - [session.StreamingDetectIntentRequest], - session.StreamingDetectIntentResponse]: - # 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._StreamingDetectIntent(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_location(self): - return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore - - class _GetLocation(SessionsRestStub): - def __call__(self, - request: locations_pb2.GetLocationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.Location: - - r"""Call the get location method over HTTP. - - Args: - request (locations_pb2.GetLocationRequest): - The request object for GetLocation 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: - locations_pb2.Location: Response from GetLocation method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*}', - }, - ] - - request, metadata = self._interceptor.pre_get_location(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 = locations_pb2.Location() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_get_location(resp) - return resp - - @property - def list_locations(self): - return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore - - class _ListLocations(SessionsRestStub): - def __call__(self, - request: locations_pb2.ListLocationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.ListLocationsResponse: - - r"""Call the list locations method over HTTP. - - Args: - request (locations_pb2.ListLocationsRequest): - The request object for ListLocations 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: - locations_pb2.ListLocationsResponse: Response from ListLocations method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*}/locations', - }, - ] - - request, metadata = self._interceptor.pre_list_locations(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 = locations_pb2.ListLocationsResponse() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_list_locations(resp) - return resp - - @property - def cancel_operation(self): - return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore - - class _CancelOperation(SessionsRestStub): - 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': '/v3/{name=projects/*/operations/*}:cancel', - }, -{ - 'method': 'post', - 'uri': '/v3/{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(SessionsRestStub): - 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': '/v3/{name=projects/*/operations/*}', - }, -{ - 'method': 'get', - 'uri': '/v3/{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(SessionsRestStub): - 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': '/v3/{name=projects/*}/operations', - }, -{ - 'method': 'get', - 'uri': '/v3/{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__=( - 'SessionsRestTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/__init__.py deleted file mode 100644 index 1e230178..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/__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 TestCasesClient -from .async_client import TestCasesAsyncClient - -__all__ = ( - 'TestCasesClient', - 'TestCasesAsyncClient', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/async_client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/async_client.py deleted file mode 100644 index 50ab44e6..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/async_client.py +++ /dev/null @@ -1,1737 +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.dialogflowcx_v3 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.dialogflowcx_v3.services.test_cases import pagers -from google.cloud.dialogflowcx_v3.types import test_case -from google.cloud.dialogflowcx_v3.types import test_case as gcdc_test_case -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import TestCasesTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import TestCasesGrpcAsyncIOTransport -from .client import TestCasesClient - - -class TestCasesAsyncClient: - """Service for managing [Test - Cases][google.cloud.dialogflow.cx.v3.TestCase] and [Test Case - Results][google.cloud.dialogflow.cx.v3.TestCaseResult]. - """ - - _client: TestCasesClient - - DEFAULT_ENDPOINT = TestCasesClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = TestCasesClient.DEFAULT_MTLS_ENDPOINT - - agent_path = staticmethod(TestCasesClient.agent_path) - parse_agent_path = staticmethod(TestCasesClient.parse_agent_path) - entity_type_path = staticmethod(TestCasesClient.entity_type_path) - parse_entity_type_path = staticmethod(TestCasesClient.parse_entity_type_path) - environment_path = staticmethod(TestCasesClient.environment_path) - parse_environment_path = staticmethod(TestCasesClient.parse_environment_path) - flow_path = staticmethod(TestCasesClient.flow_path) - parse_flow_path = staticmethod(TestCasesClient.parse_flow_path) - intent_path = staticmethod(TestCasesClient.intent_path) - parse_intent_path = staticmethod(TestCasesClient.parse_intent_path) - page_path = staticmethod(TestCasesClient.page_path) - parse_page_path = staticmethod(TestCasesClient.parse_page_path) - test_case_path = staticmethod(TestCasesClient.test_case_path) - parse_test_case_path = staticmethod(TestCasesClient.parse_test_case_path) - test_case_result_path = staticmethod(TestCasesClient.test_case_result_path) - parse_test_case_result_path = staticmethod(TestCasesClient.parse_test_case_result_path) - transition_route_group_path = staticmethod(TestCasesClient.transition_route_group_path) - parse_transition_route_group_path = staticmethod(TestCasesClient.parse_transition_route_group_path) - webhook_path = staticmethod(TestCasesClient.webhook_path) - parse_webhook_path = staticmethod(TestCasesClient.parse_webhook_path) - common_billing_account_path = staticmethod(TestCasesClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(TestCasesClient.parse_common_billing_account_path) - common_folder_path = staticmethod(TestCasesClient.common_folder_path) - parse_common_folder_path = staticmethod(TestCasesClient.parse_common_folder_path) - common_organization_path = staticmethod(TestCasesClient.common_organization_path) - parse_common_organization_path = staticmethod(TestCasesClient.parse_common_organization_path) - common_project_path = staticmethod(TestCasesClient.common_project_path) - parse_common_project_path = staticmethod(TestCasesClient.parse_common_project_path) - common_location_path = staticmethod(TestCasesClient.common_location_path) - parse_common_location_path = staticmethod(TestCasesClient.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: - TestCasesAsyncClient: The constructed client. - """ - return TestCasesClient.from_service_account_info.__func__(TestCasesAsyncClient, 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: - TestCasesAsyncClient: The constructed client. - """ - return TestCasesClient.from_service_account_file.__func__(TestCasesAsyncClient, 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 TestCasesClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> TestCasesTransport: - """Returns the transport used by the client instance. - - Returns: - TestCasesTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(TestCasesClient).get_transport_class, type(TestCasesClient)) - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, TestCasesTransport] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the test cases 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, ~.TestCasesTransport]): 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 = TestCasesClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def list_test_cases(self, - request: Optional[Union[test_case.ListTestCasesRequest, 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.ListTestCasesAsyncPager: - r"""Fetches a list of test cases for a given agent. - - .. 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 dialogflowcx_v3 - - async def sample_list_test_cases(): - # Create a client - client = dialogflowcx_v3.TestCasesAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListTestCasesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_test_cases(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ListTestCasesRequest, dict]]): - The request object. The request message for - [TestCases.ListTestCases][google.cloud.dialogflow.cx.v3.TestCases.ListTestCases]. - parent (:class:`str`): - Required. The agent to list all pages for. Format: - ``projects//locations//agents/``. - - 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.dialogflowcx_v3.services.test_cases.pagers.ListTestCasesAsyncPager: - The response message for - [TestCases.ListTestCases][google.cloud.dialogflow.cx.v3.TestCases.ListTestCases]. - - 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 = test_case.ListTestCasesRequest(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_test_cases, - 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.ListTestCasesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def batch_delete_test_cases(self, - request: Optional[Union[test_case.BatchDeleteTestCasesRequest, 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]] = (), - ) -> None: - r"""Batch deletes test cases. - - .. 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 dialogflowcx_v3 - - async def sample_batch_delete_test_cases(): - # Create a client - client = dialogflowcx_v3.TestCasesAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.BatchDeleteTestCasesRequest( - parent="parent_value", - names=['names_value1', 'names_value2'], - ) - - # Make the request - await client.batch_delete_test_cases(request=request) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.BatchDeleteTestCasesRequest, dict]]): - The request object. The request message for - [TestCases.BatchDeleteTestCases][google.cloud.dialogflow.cx.v3.TestCases.BatchDeleteTestCases]. - parent (:class:`str`): - Required. The agent to delete test cases from. Format: - ``projects//locations//agents/``. - - 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. - """ - # 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 = test_case.BatchDeleteTestCasesRequest(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.batch_delete_test_cases, - 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. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def get_test_case(self, - request: Optional[Union[test_case.GetTestCaseRequest, 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]] = (), - ) -> test_case.TestCase: - r"""Gets a test case. - - .. 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 dialogflowcx_v3 - - async def sample_get_test_case(): - # Create a client - client = dialogflowcx_v3.TestCasesAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetTestCaseRequest( - name="name_value", - ) - - # Make the request - response = await client.get_test_case(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.GetTestCaseRequest, dict]]): - The request object. The request message for - [TestCases.GetTestCase][google.cloud.dialogflow.cx.v3.TestCases.GetTestCase]. - name (:class:`str`): - Required. The name of the testcase. Format: - ``projects//locations//agents//testCases/``. - - 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.dialogflowcx_v3.types.TestCase: - Represents a test case. - """ - # 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 = test_case.GetTestCaseRequest(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_test_case, - 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 create_test_case(self, - request: Optional[Union[gcdc_test_case.CreateTestCaseRequest, dict]] = None, - *, - parent: Optional[str] = None, - test_case: Optional[gcdc_test_case.TestCase] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_test_case.TestCase: - r"""Creates a test case for the given agent. - - .. 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 dialogflowcx_v3 - - async def sample_create_test_case(): - # Create a client - client = dialogflowcx_v3.TestCasesAsyncClient() - - # Initialize request argument(s) - test_case = dialogflowcx_v3.TestCase() - test_case.display_name = "display_name_value" - - request = dialogflowcx_v3.CreateTestCaseRequest( - parent="parent_value", - test_case=test_case, - ) - - # Make the request - response = await client.create_test_case(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.CreateTestCaseRequest, dict]]): - The request object. The request message for - [TestCases.CreateTestCase][google.cloud.dialogflow.cx.v3.TestCases.CreateTestCase]. - parent (:class:`str`): - Required. The agent to create the test case for. Format: - ``projects//locations//agents/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - test_case (:class:`google.cloud.dialogflowcx_v3.types.TestCase`): - Required. The test case to create. - This corresponds to the ``test_case`` 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.dialogflowcx_v3.types.TestCase: - Represents a test case. - """ - # 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, test_case]) - 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 = gcdc_test_case.CreateTestCaseRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if test_case is not None: - request.test_case = test_case - - # 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_test_case, - 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_test_case(self, - request: Optional[Union[gcdc_test_case.UpdateTestCaseRequest, dict]] = None, - *, - test_case: Optional[gcdc_test_case.TestCase] = 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]] = (), - ) -> gcdc_test_case.TestCase: - r"""Updates the specified test case. - - .. 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 dialogflowcx_v3 - - async def sample_update_test_case(): - # Create a client - client = dialogflowcx_v3.TestCasesAsyncClient() - - # Initialize request argument(s) - test_case = dialogflowcx_v3.TestCase() - test_case.display_name = "display_name_value" - - request = dialogflowcx_v3.UpdateTestCaseRequest( - test_case=test_case, - ) - - # Make the request - response = await client.update_test_case(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.UpdateTestCaseRequest, dict]]): - The request object. The request message for - [TestCases.UpdateTestCase][google.cloud.dialogflow.cx.v3.TestCases.UpdateTestCase]. - test_case (:class:`google.cloud.dialogflowcx_v3.types.TestCase`): - Required. The test case to update. - This corresponds to the ``test_case`` 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 mask to specify which fields should be - updated. The - [``creationTime``][google.cloud.dialogflow.cx.v3.TestCase.creation_time] - and - [``lastTestResult``][google.cloud.dialogflow.cx.v3.TestCase.last_test_result] - cannot 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.dialogflowcx_v3.types.TestCase: - Represents a test case. - """ - # 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([test_case, 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 = gcdc_test_case.UpdateTestCaseRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if test_case is not None: - request.test_case = test_case - 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_test_case, - 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(( - ("test_case.name", request.test_case.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def run_test_case(self, - request: Optional[Union[test_case.RunTestCaseRequest, 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"""Kicks off a test case run. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [RunTestCaseMetadata][google.cloud.dialogflow.cx.v3.RunTestCaseMetadata] - - ``response``: - [RunTestCaseResponse][google.cloud.dialogflow.cx.v3.RunTestCaseResponse] - - .. 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 dialogflowcx_v3 - - async def sample_run_test_case(): - # Create a client - client = dialogflowcx_v3.TestCasesAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.RunTestCaseRequest( - name="name_value", - ) - - # Make the request - operation = client.run_test_case(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.RunTestCaseRequest, dict]]): - The request object. The request message for - [TestCases.RunTestCase][google.cloud.dialogflow.cx.v3.TestCases.RunTestCase]. - 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.dialogflowcx_v3.types.RunTestCaseResponse` The response message for - [TestCases.RunTestCase][google.cloud.dialogflow.cx.v3.TestCases.RunTestCase]. - - """ - # Create or coerce a protobuf request object. - request = test_case.RunTestCaseRequest(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.run_test_case, - 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, - test_case.RunTestCaseResponse, - metadata_type=test_case.RunTestCaseMetadata, - ) - - # Done; return the response. - return response - - async def batch_run_test_cases(self, - request: Optional[Union[test_case.BatchRunTestCasesRequest, 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"""Kicks off a batch run of test cases. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [BatchRunTestCasesMetadata][google.cloud.dialogflow.cx.v3.BatchRunTestCasesMetadata] - - ``response``: - [BatchRunTestCasesResponse][google.cloud.dialogflow.cx.v3.BatchRunTestCasesResponse] - - .. 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 dialogflowcx_v3 - - async def sample_batch_run_test_cases(): - # Create a client - client = dialogflowcx_v3.TestCasesAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.BatchRunTestCasesRequest( - parent="parent_value", - test_cases=['test_cases_value1', 'test_cases_value2'], - ) - - # Make the request - operation = client.batch_run_test_cases(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.BatchRunTestCasesRequest, dict]]): - The request object. The request message for - [TestCases.BatchRunTestCases][google.cloud.dialogflow.cx.v3.TestCases.BatchRunTestCases]. - 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.dialogflowcx_v3.types.BatchRunTestCasesResponse` The response message for - [TestCases.BatchRunTestCases][google.cloud.dialogflow.cx.v3.TestCases.BatchRunTestCases]. - - """ - # Create or coerce a protobuf request object. - request = test_case.BatchRunTestCasesRequest(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.batch_run_test_cases, - 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, - test_case.BatchRunTestCasesResponse, - metadata_type=test_case.BatchRunTestCasesMetadata, - ) - - # Done; return the response. - return response - - async def calculate_coverage(self, - request: Optional[Union[test_case.CalculateCoverageRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> test_case.CalculateCoverageResponse: - r"""Calculates the test coverage for an agent. - - .. 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 dialogflowcx_v3 - - async def sample_calculate_coverage(): - # Create a client - client = dialogflowcx_v3.TestCasesAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.CalculateCoverageRequest( - agent="agent_value", - type_="TRANSITION_ROUTE_GROUP", - ) - - # Make the request - response = await client.calculate_coverage(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.CalculateCoverageRequest, dict]]): - The request object. The request message for - [TestCases.CalculateCoverage][google.cloud.dialogflow.cx.v3.TestCases.CalculateCoverage]. - 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.dialogflowcx_v3.types.CalculateCoverageResponse: - The response message for - [TestCases.CalculateCoverage][google.cloud.dialogflow.cx.v3.TestCases.CalculateCoverage]. - - """ - # Create or coerce a protobuf request object. - request = test_case.CalculateCoverageRequest(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.calculate_coverage, - 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(( - ("agent", request.agent), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def import_test_cases(self, - request: Optional[Union[test_case.ImportTestCasesRequest, 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"""Imports the test cases from a Cloud Storage bucket or a local - file. It always creates new test cases and won't overwrite any - existing ones. The provided ID in the imported test case is - neglected. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [ImportTestCasesMetadata][google.cloud.dialogflow.cx.v3.ImportTestCasesMetadata] - - ``response``: - [ImportTestCasesResponse][google.cloud.dialogflow.cx.v3.ImportTestCasesResponse] - - .. 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 dialogflowcx_v3 - - async def sample_import_test_cases(): - # Create a client - client = dialogflowcx_v3.TestCasesAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ImportTestCasesRequest( - gcs_uri="gcs_uri_value", - parent="parent_value", - ) - - # Make the request - operation = client.import_test_cases(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ImportTestCasesRequest, dict]]): - The request object. The request message for - [TestCases.ImportTestCases][google.cloud.dialogflow.cx.v3.TestCases.ImportTestCases]. - 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.dialogflowcx_v3.types.ImportTestCasesResponse` The response message for - [TestCases.ImportTestCases][google.cloud.dialogflow.cx.v3.TestCases.ImportTestCases]. - - """ - # Create or coerce a protobuf request object. - request = test_case.ImportTestCasesRequest(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.import_test_cases, - 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, - test_case.ImportTestCasesResponse, - metadata_type=test_case.ImportTestCasesMetadata, - ) - - # Done; return the response. - return response - - async def export_test_cases(self, - request: Optional[Union[test_case.ExportTestCasesRequest, 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"""Exports the test cases under the agent to a Cloud Storage bucket - or a local file. Filter can be applied to export a subset of - test cases. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [ExportTestCasesMetadata][google.cloud.dialogflow.cx.v3.ExportTestCasesMetadata] - - ``response``: - [ExportTestCasesResponse][google.cloud.dialogflow.cx.v3.ExportTestCasesResponse] - - .. 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 dialogflowcx_v3 - - async def sample_export_test_cases(): - # Create a client - client = dialogflowcx_v3.TestCasesAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ExportTestCasesRequest( - gcs_uri="gcs_uri_value", - parent="parent_value", - ) - - # Make the request - operation = client.export_test_cases(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ExportTestCasesRequest, dict]]): - The request object. The request message for - [TestCases.ExportTestCases][google.cloud.dialogflow.cx.v3.TestCases.ExportTestCases]. - 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.dialogflowcx_v3.types.ExportTestCasesResponse` The response message for - [TestCases.ExportTestCases][google.cloud.dialogflow.cx.v3.TestCases.ExportTestCases]. - - """ - # Create or coerce a protobuf request object. - request = test_case.ExportTestCasesRequest(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.export_test_cases, - 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, - test_case.ExportTestCasesResponse, - metadata_type=test_case.ExportTestCasesMetadata, - ) - - # Done; return the response. - return response - - async def list_test_case_results(self, - request: Optional[Union[test_case.ListTestCaseResultsRequest, 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.ListTestCaseResultsAsyncPager: - r"""Fetches the list of run results for the given test - case. A maximum of 100 results are kept for each test - case. - - .. 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 dialogflowcx_v3 - - async def sample_list_test_case_results(): - # Create a client - client = dialogflowcx_v3.TestCasesAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListTestCaseResultsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_test_case_results(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ListTestCaseResultsRequest, dict]]): - The request object. The request message for - [TestCases.ListTestCaseResults][google.cloud.dialogflow.cx.v3.TestCases.ListTestCaseResults]. - parent (:class:`str`): - Required. The test case to list results for. Format: - ``projects//locations//agents// testCases/``. - Specify a ``-`` as a wildcard for TestCase ID to list - results across multiple test cases. - - 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.dialogflowcx_v3.services.test_cases.pagers.ListTestCaseResultsAsyncPager: - The response message for - [TestCases.ListTestCaseResults][google.cloud.dialogflow.cx.v3.TestCases.ListTestCaseResults]. - - 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 = test_case.ListTestCaseResultsRequest(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_test_case_results, - 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.ListTestCaseResultsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_test_case_result(self, - request: Optional[Union[test_case.GetTestCaseResultRequest, 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]] = (), - ) -> test_case.TestCaseResult: - r"""Gets a test case result. - - .. 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 dialogflowcx_v3 - - async def sample_get_test_case_result(): - # Create a client - client = dialogflowcx_v3.TestCasesAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetTestCaseResultRequest( - name="name_value", - ) - - # Make the request - response = await client.get_test_case_result(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.GetTestCaseResultRequest, dict]]): - The request object. The request message for - [TestCases.GetTestCaseResult][google.cloud.dialogflow.cx.v3.TestCases.GetTestCaseResult]. - name (:class:`str`): - Required. The name of the testcase. Format: - ``projects//locations//agents//testCases//results/``. - - 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.dialogflowcx_v3.types.TestCaseResult: - Represents a result from running a - test case in an agent environment. - - """ - # 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 = test_case.GetTestCaseResultRequest(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_test_case_result, - 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_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 get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**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_location, - 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_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**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_locations, - 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 __aenter__(self) -> "TestCasesAsyncClient": - 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__ = ( - "TestCasesAsyncClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/client.py deleted file mode 100644 index c5a23144..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/client.py +++ /dev/null @@ -1,2022 +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.dialogflowcx_v3 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.dialogflowcx_v3.services.test_cases import pagers -from google.cloud.dialogflowcx_v3.types import test_case -from google.cloud.dialogflowcx_v3.types import test_case as gcdc_test_case -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import TestCasesTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import TestCasesGrpcTransport -from .transports.grpc_asyncio import TestCasesGrpcAsyncIOTransport -from .transports.rest import TestCasesRestTransport - - -class TestCasesClientMeta(type): - """Metaclass for the TestCases 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[TestCasesTransport]] - _transport_registry["grpc"] = TestCasesGrpcTransport - _transport_registry["grpc_asyncio"] = TestCasesGrpcAsyncIOTransport - _transport_registry["rest"] = TestCasesRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[TestCasesTransport]: - """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 TestCasesClient(metaclass=TestCasesClientMeta): - """Service for managing [Test - Cases][google.cloud.dialogflow.cx.v3.TestCase] and [Test Case - Results][google.cloud.dialogflow.cx.v3.TestCaseResult]. - """ - - @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 = "dialogflow.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: - TestCasesClient: 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: - TestCasesClient: 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) -> TestCasesTransport: - """Returns the transport used by the client instance. - - Returns: - TestCasesTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def agent_path(project: str,location: str,agent: str,) -> str: - """Returns a fully-qualified agent string.""" - return "projects/{project}/locations/{location}/agents/{agent}".format(project=project, location=location, agent=agent, ) - - @staticmethod - def parse_agent_path(path: str) -> Dict[str,str]: - """Parses a agent path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def entity_type_path(project: str,location: str,agent: str,entity_type: str,) -> str: - """Returns a fully-qualified entity_type string.""" - return "projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type}".format(project=project, location=location, agent=agent, entity_type=entity_type, ) - - @staticmethod - def parse_entity_type_path(path: str) -> Dict[str,str]: - """Parses a entity_type path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/entityTypes/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def environment_path(project: str,location: str,agent: str,environment: str,) -> str: - """Returns a fully-qualified environment string.""" - return "projects/{project}/locations/{location}/agents/{agent}/environments/{environment}".format(project=project, location=location, agent=agent, environment=environment, ) - - @staticmethod - def parse_environment_path(path: str) -> Dict[str,str]: - """Parses a environment path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/environments/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def flow_path(project: str,location: str,agent: str,flow: str,) -> str: - """Returns a fully-qualified flow string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}".format(project=project, location=location, agent=agent, flow=flow, ) - - @staticmethod - def parse_flow_path(path: str) -> Dict[str,str]: - """Parses a flow path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def intent_path(project: str,location: str,agent: str,intent: str,) -> str: - """Returns a fully-qualified intent string.""" - return "projects/{project}/locations/{location}/agents/{agent}/intents/{intent}".format(project=project, location=location, agent=agent, intent=intent, ) - - @staticmethod - def parse_intent_path(path: str) -> Dict[str,str]: - """Parses a intent path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/intents/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def page_path(project: str,location: str,agent: str,flow: str,page: str,) -> str: - """Returns a fully-qualified page string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page}".format(project=project, location=location, agent=agent, flow=flow, page=page, ) - - @staticmethod - def parse_page_path(path: str) -> Dict[str,str]: - """Parses a page path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)/pages/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def test_case_path(project: str,location: str,agent: str,test_case: str,) -> str: - """Returns a fully-qualified test_case string.""" - return "projects/{project}/locations/{location}/agents/{agent}/testCases/{test_case}".format(project=project, location=location, agent=agent, test_case=test_case, ) - - @staticmethod - def parse_test_case_path(path: str) -> Dict[str,str]: - """Parses a test_case path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/testCases/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def test_case_result_path(project: str,location: str,agent: str,test_case: str,result: str,) -> str: - """Returns a fully-qualified test_case_result string.""" - return "projects/{project}/locations/{location}/agents/{agent}/testCases/{test_case}/results/{result}".format(project=project, location=location, agent=agent, test_case=test_case, result=result, ) - - @staticmethod - def parse_test_case_result_path(path: str) -> Dict[str,str]: - """Parses a test_case_result path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/testCases/(?P.+?)/results/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def transition_route_group_path(project: str,location: str,agent: str,flow: str,transition_route_group: str,) -> str: - """Returns a fully-qualified transition_route_group string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}".format(project=project, location=location, agent=agent, flow=flow, transition_route_group=transition_route_group, ) - - @staticmethod - def parse_transition_route_group_path(path: str) -> Dict[str,str]: - """Parses a transition_route_group path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)/transitionRouteGroups/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def webhook_path(project: str,location: str,agent: str,webhook: str,) -> str: - """Returns a fully-qualified webhook string.""" - return "projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}".format(project=project, location=location, agent=agent, webhook=webhook, ) - - @staticmethod - def parse_webhook_path(path: str) -> Dict[str,str]: - """Parses a webhook path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/webhooks/(?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, TestCasesTransport]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the test cases 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, TestCasesTransport]): 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, TestCasesTransport): - # transport is a TestCasesTransport 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 list_test_cases(self, - request: Optional[Union[test_case.ListTestCasesRequest, 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.ListTestCasesPager: - r"""Fetches a list of test cases for a given agent. - - .. 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 dialogflowcx_v3 - - def sample_list_test_cases(): - # Create a client - client = dialogflowcx_v3.TestCasesClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListTestCasesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_test_cases(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ListTestCasesRequest, dict]): - The request object. The request message for - [TestCases.ListTestCases][google.cloud.dialogflow.cx.v3.TestCases.ListTestCases]. - parent (str): - Required. The agent to list all pages for. Format: - ``projects//locations//agents/``. - - 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.dialogflowcx_v3.services.test_cases.pagers.ListTestCasesPager: - The response message for - [TestCases.ListTestCases][google.cloud.dialogflow.cx.v3.TestCases.ListTestCases]. - - 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 test_case.ListTestCasesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, test_case.ListTestCasesRequest): - request = test_case.ListTestCasesRequest(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_test_cases] - - # 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.ListTestCasesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def batch_delete_test_cases(self, - request: Optional[Union[test_case.BatchDeleteTestCasesRequest, 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]] = (), - ) -> None: - r"""Batch deletes test cases. - - .. 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 dialogflowcx_v3 - - def sample_batch_delete_test_cases(): - # Create a client - client = dialogflowcx_v3.TestCasesClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.BatchDeleteTestCasesRequest( - parent="parent_value", - names=['names_value1', 'names_value2'], - ) - - # Make the request - client.batch_delete_test_cases(request=request) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.BatchDeleteTestCasesRequest, dict]): - The request object. The request message for - [TestCases.BatchDeleteTestCases][google.cloud.dialogflow.cx.v3.TestCases.BatchDeleteTestCases]. - parent (str): - Required. The agent to delete test cases from. Format: - ``projects//locations//agents/``. - - 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. - """ - # 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 test_case.BatchDeleteTestCasesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, test_case.BatchDeleteTestCasesRequest): - request = test_case.BatchDeleteTestCasesRequest(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.batch_delete_test_cases] - - # 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. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def get_test_case(self, - request: Optional[Union[test_case.GetTestCaseRequest, 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]] = (), - ) -> test_case.TestCase: - r"""Gets a test case. - - .. 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 dialogflowcx_v3 - - def sample_get_test_case(): - # Create a client - client = dialogflowcx_v3.TestCasesClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetTestCaseRequest( - name="name_value", - ) - - # Make the request - response = client.get_test_case(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.GetTestCaseRequest, dict]): - The request object. The request message for - [TestCases.GetTestCase][google.cloud.dialogflow.cx.v3.TestCases.GetTestCase]. - name (str): - Required. The name of the testcase. Format: - ``projects//locations//agents//testCases/``. - - 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.dialogflowcx_v3.types.TestCase: - Represents a test case. - """ - # 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 test_case.GetTestCaseRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, test_case.GetTestCaseRequest): - request = test_case.GetTestCaseRequest(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_test_case] - - # 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 create_test_case(self, - request: Optional[Union[gcdc_test_case.CreateTestCaseRequest, dict]] = None, - *, - parent: Optional[str] = None, - test_case: Optional[gcdc_test_case.TestCase] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_test_case.TestCase: - r"""Creates a test case for the given agent. - - .. 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 dialogflowcx_v3 - - def sample_create_test_case(): - # Create a client - client = dialogflowcx_v3.TestCasesClient() - - # Initialize request argument(s) - test_case = dialogflowcx_v3.TestCase() - test_case.display_name = "display_name_value" - - request = dialogflowcx_v3.CreateTestCaseRequest( - parent="parent_value", - test_case=test_case, - ) - - # Make the request - response = client.create_test_case(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.CreateTestCaseRequest, dict]): - The request object. The request message for - [TestCases.CreateTestCase][google.cloud.dialogflow.cx.v3.TestCases.CreateTestCase]. - parent (str): - Required. The agent to create the test case for. Format: - ``projects//locations//agents/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - test_case (google.cloud.dialogflowcx_v3.types.TestCase): - Required. The test case to create. - This corresponds to the ``test_case`` 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.dialogflowcx_v3.types.TestCase: - Represents a test case. - """ - # 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, test_case]) - 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 gcdc_test_case.CreateTestCaseRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_test_case.CreateTestCaseRequest): - request = gcdc_test_case.CreateTestCaseRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if test_case is not None: - request.test_case = test_case - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_test_case] - - # 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_test_case(self, - request: Optional[Union[gcdc_test_case.UpdateTestCaseRequest, dict]] = None, - *, - test_case: Optional[gcdc_test_case.TestCase] = 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]] = (), - ) -> gcdc_test_case.TestCase: - r"""Updates the specified test case. - - .. 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 dialogflowcx_v3 - - def sample_update_test_case(): - # Create a client - client = dialogflowcx_v3.TestCasesClient() - - # Initialize request argument(s) - test_case = dialogflowcx_v3.TestCase() - test_case.display_name = "display_name_value" - - request = dialogflowcx_v3.UpdateTestCaseRequest( - test_case=test_case, - ) - - # Make the request - response = client.update_test_case(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.UpdateTestCaseRequest, dict]): - The request object. The request message for - [TestCases.UpdateTestCase][google.cloud.dialogflow.cx.v3.TestCases.UpdateTestCase]. - test_case (google.cloud.dialogflowcx_v3.types.TestCase): - Required. The test case to update. - This corresponds to the ``test_case`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The mask to specify which fields should be - updated. The - [``creationTime``][google.cloud.dialogflow.cx.v3.TestCase.creation_time] - and - [``lastTestResult``][google.cloud.dialogflow.cx.v3.TestCase.last_test_result] - cannot 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.dialogflowcx_v3.types.TestCase: - Represents a test case. - """ - # 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([test_case, 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 gcdc_test_case.UpdateTestCaseRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_test_case.UpdateTestCaseRequest): - request = gcdc_test_case.UpdateTestCaseRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if test_case is not None: - request.test_case = test_case - 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_test_case] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("test_case.name", request.test_case.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def run_test_case(self, - request: Optional[Union[test_case.RunTestCaseRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Kicks off a test case run. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [RunTestCaseMetadata][google.cloud.dialogflow.cx.v3.RunTestCaseMetadata] - - ``response``: - [RunTestCaseResponse][google.cloud.dialogflow.cx.v3.RunTestCaseResponse] - - .. 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 dialogflowcx_v3 - - def sample_run_test_case(): - # Create a client - client = dialogflowcx_v3.TestCasesClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.RunTestCaseRequest( - name="name_value", - ) - - # Make the request - operation = client.run_test_case(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.RunTestCaseRequest, dict]): - The request object. The request message for - [TestCases.RunTestCase][google.cloud.dialogflow.cx.v3.TestCases.RunTestCase]. - 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.dialogflowcx_v3.types.RunTestCaseResponse` The response message for - [TestCases.RunTestCase][google.cloud.dialogflow.cx.v3.TestCases.RunTestCase]. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a test_case.RunTestCaseRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, test_case.RunTestCaseRequest): - request = test_case.RunTestCaseRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.run_test_case] - - # 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, - test_case.RunTestCaseResponse, - metadata_type=test_case.RunTestCaseMetadata, - ) - - # Done; return the response. - return response - - def batch_run_test_cases(self, - request: Optional[Union[test_case.BatchRunTestCasesRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Kicks off a batch run of test cases. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [BatchRunTestCasesMetadata][google.cloud.dialogflow.cx.v3.BatchRunTestCasesMetadata] - - ``response``: - [BatchRunTestCasesResponse][google.cloud.dialogflow.cx.v3.BatchRunTestCasesResponse] - - .. 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 dialogflowcx_v3 - - def sample_batch_run_test_cases(): - # Create a client - client = dialogflowcx_v3.TestCasesClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.BatchRunTestCasesRequest( - parent="parent_value", - test_cases=['test_cases_value1', 'test_cases_value2'], - ) - - # Make the request - operation = client.batch_run_test_cases(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.BatchRunTestCasesRequest, dict]): - The request object. The request message for - [TestCases.BatchRunTestCases][google.cloud.dialogflow.cx.v3.TestCases.BatchRunTestCases]. - 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.dialogflowcx_v3.types.BatchRunTestCasesResponse` The response message for - [TestCases.BatchRunTestCases][google.cloud.dialogflow.cx.v3.TestCases.BatchRunTestCases]. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a test_case.BatchRunTestCasesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, test_case.BatchRunTestCasesRequest): - request = test_case.BatchRunTestCasesRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.batch_run_test_cases] - - # 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, - test_case.BatchRunTestCasesResponse, - metadata_type=test_case.BatchRunTestCasesMetadata, - ) - - # Done; return the response. - return response - - def calculate_coverage(self, - request: Optional[Union[test_case.CalculateCoverageRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> test_case.CalculateCoverageResponse: - r"""Calculates the test coverage for an agent. - - .. 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 dialogflowcx_v3 - - def sample_calculate_coverage(): - # Create a client - client = dialogflowcx_v3.TestCasesClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.CalculateCoverageRequest( - agent="agent_value", - type_="TRANSITION_ROUTE_GROUP", - ) - - # Make the request - response = client.calculate_coverage(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.CalculateCoverageRequest, dict]): - The request object. The request message for - [TestCases.CalculateCoverage][google.cloud.dialogflow.cx.v3.TestCases.CalculateCoverage]. - 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.dialogflowcx_v3.types.CalculateCoverageResponse: - The response message for - [TestCases.CalculateCoverage][google.cloud.dialogflow.cx.v3.TestCases.CalculateCoverage]. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a test_case.CalculateCoverageRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, test_case.CalculateCoverageRequest): - request = test_case.CalculateCoverageRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.calculate_coverage] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("agent", request.agent), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def import_test_cases(self, - request: Optional[Union[test_case.ImportTestCasesRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Imports the test cases from a Cloud Storage bucket or a local - file. It always creates new test cases and won't overwrite any - existing ones. The provided ID in the imported test case is - neglected. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [ImportTestCasesMetadata][google.cloud.dialogflow.cx.v3.ImportTestCasesMetadata] - - ``response``: - [ImportTestCasesResponse][google.cloud.dialogflow.cx.v3.ImportTestCasesResponse] - - .. 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 dialogflowcx_v3 - - def sample_import_test_cases(): - # Create a client - client = dialogflowcx_v3.TestCasesClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ImportTestCasesRequest( - gcs_uri="gcs_uri_value", - parent="parent_value", - ) - - # Make the request - operation = client.import_test_cases(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ImportTestCasesRequest, dict]): - The request object. The request message for - [TestCases.ImportTestCases][google.cloud.dialogflow.cx.v3.TestCases.ImportTestCases]. - 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.dialogflowcx_v3.types.ImportTestCasesResponse` The response message for - [TestCases.ImportTestCases][google.cloud.dialogflow.cx.v3.TestCases.ImportTestCases]. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a test_case.ImportTestCasesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, test_case.ImportTestCasesRequest): - request = test_case.ImportTestCasesRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.import_test_cases] - - # 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, - test_case.ImportTestCasesResponse, - metadata_type=test_case.ImportTestCasesMetadata, - ) - - # Done; return the response. - return response - - def export_test_cases(self, - request: Optional[Union[test_case.ExportTestCasesRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Exports the test cases under the agent to a Cloud Storage bucket - or a local file. Filter can be applied to export a subset of - test cases. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [ExportTestCasesMetadata][google.cloud.dialogflow.cx.v3.ExportTestCasesMetadata] - - ``response``: - [ExportTestCasesResponse][google.cloud.dialogflow.cx.v3.ExportTestCasesResponse] - - .. 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 dialogflowcx_v3 - - def sample_export_test_cases(): - # Create a client - client = dialogflowcx_v3.TestCasesClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ExportTestCasesRequest( - gcs_uri="gcs_uri_value", - parent="parent_value", - ) - - # Make the request - operation = client.export_test_cases(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ExportTestCasesRequest, dict]): - The request object. The request message for - [TestCases.ExportTestCases][google.cloud.dialogflow.cx.v3.TestCases.ExportTestCases]. - 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.dialogflowcx_v3.types.ExportTestCasesResponse` The response message for - [TestCases.ExportTestCases][google.cloud.dialogflow.cx.v3.TestCases.ExportTestCases]. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a test_case.ExportTestCasesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, test_case.ExportTestCasesRequest): - request = test_case.ExportTestCasesRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.export_test_cases] - - # 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, - test_case.ExportTestCasesResponse, - metadata_type=test_case.ExportTestCasesMetadata, - ) - - # Done; return the response. - return response - - def list_test_case_results(self, - request: Optional[Union[test_case.ListTestCaseResultsRequest, 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.ListTestCaseResultsPager: - r"""Fetches the list of run results for the given test - case. A maximum of 100 results are kept for each test - case. - - .. 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 dialogflowcx_v3 - - def sample_list_test_case_results(): - # Create a client - client = dialogflowcx_v3.TestCasesClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListTestCaseResultsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_test_case_results(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ListTestCaseResultsRequest, dict]): - The request object. The request message for - [TestCases.ListTestCaseResults][google.cloud.dialogflow.cx.v3.TestCases.ListTestCaseResults]. - parent (str): - Required. The test case to list results for. Format: - ``projects//locations//agents// testCases/``. - Specify a ``-`` as a wildcard for TestCase ID to list - results across multiple test cases. - - 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.dialogflowcx_v3.services.test_cases.pagers.ListTestCaseResultsPager: - The response message for - [TestCases.ListTestCaseResults][google.cloud.dialogflow.cx.v3.TestCases.ListTestCaseResults]. - - 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 test_case.ListTestCaseResultsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, test_case.ListTestCaseResultsRequest): - request = test_case.ListTestCaseResultsRequest(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_test_case_results] - - # 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.ListTestCaseResultsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_test_case_result(self, - request: Optional[Union[test_case.GetTestCaseResultRequest, 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]] = (), - ) -> test_case.TestCaseResult: - r"""Gets a test case result. - - .. 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 dialogflowcx_v3 - - def sample_get_test_case_result(): - # Create a client - client = dialogflowcx_v3.TestCasesClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetTestCaseResultRequest( - name="name_value", - ) - - # Make the request - response = client.get_test_case_result(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.GetTestCaseResultRequest, dict]): - The request object. The request message for - [TestCases.GetTestCaseResult][google.cloud.dialogflow.cx.v3.TestCases.GetTestCaseResult]. - name (str): - Required. The name of the testcase. Format: - ``projects//locations//agents//testCases//results/``. - - 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.dialogflowcx_v3.types.TestCaseResult: - Represents a result from running a - test case in an agent environment. - - """ - # 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 test_case.GetTestCaseResultRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, test_case.GetTestCaseResultRequest): - request = test_case.GetTestCaseResultRequest(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_test_case_result] - - # 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 __enter__(self) -> "TestCasesClient": - 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,) - - def get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.get_location, - 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 list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.list_locations, - 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 - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "TestCasesClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/pagers.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/pagers.py deleted file mode 100644 index ef627048..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/pagers.py +++ /dev/null @@ -1,260 +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.dialogflowcx_v3.types import test_case - - -class ListTestCasesPager: - """A pager for iterating through ``list_test_cases`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListTestCasesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``test_cases`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListTestCases`` requests and continue to iterate - through the ``test_cases`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListTestCasesResponse` - 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[..., test_case.ListTestCasesResponse], - request: test_case.ListTestCasesRequest, - response: test_case.ListTestCasesResponse, - *, - 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.dialogflowcx_v3.types.ListTestCasesRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListTestCasesResponse): - 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 = test_case.ListTestCasesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[test_case.ListTestCasesResponse]: - 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[test_case.TestCase]: - for page in self.pages: - yield from page.test_cases - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListTestCasesAsyncPager: - """A pager for iterating through ``list_test_cases`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListTestCasesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``test_cases`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListTestCases`` requests and continue to iterate - through the ``test_cases`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListTestCasesResponse` - 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[test_case.ListTestCasesResponse]], - request: test_case.ListTestCasesRequest, - response: test_case.ListTestCasesResponse, - *, - 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.dialogflowcx_v3.types.ListTestCasesRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListTestCasesResponse): - 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 = test_case.ListTestCasesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[test_case.ListTestCasesResponse]: - 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[test_case.TestCase]: - async def async_generator(): - async for page in self.pages: - for response in page.test_cases: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListTestCaseResultsPager: - """A pager for iterating through ``list_test_case_results`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListTestCaseResultsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``test_case_results`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListTestCaseResults`` requests and continue to iterate - through the ``test_case_results`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListTestCaseResultsResponse` - 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[..., test_case.ListTestCaseResultsResponse], - request: test_case.ListTestCaseResultsRequest, - response: test_case.ListTestCaseResultsResponse, - *, - 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.dialogflowcx_v3.types.ListTestCaseResultsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListTestCaseResultsResponse): - 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 = test_case.ListTestCaseResultsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[test_case.ListTestCaseResultsResponse]: - 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[test_case.TestCaseResult]: - for page in self.pages: - yield from page.test_case_results - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListTestCaseResultsAsyncPager: - """A pager for iterating through ``list_test_case_results`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListTestCaseResultsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``test_case_results`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListTestCaseResults`` requests and continue to iterate - through the ``test_case_results`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListTestCaseResultsResponse` - 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[test_case.ListTestCaseResultsResponse]], - request: test_case.ListTestCaseResultsRequest, - response: test_case.ListTestCaseResultsResponse, - *, - 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.dialogflowcx_v3.types.ListTestCaseResultsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListTestCaseResultsResponse): - 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 = test_case.ListTestCaseResultsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[test_case.ListTestCaseResultsResponse]: - 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[test_case.TestCaseResult]: - async def async_generator(): - async for page in self.pages: - for response in page.test_case_results: - 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/v3/google/cloud/dialogflowcx_v3/services/test_cases/transports/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/transports/__init__.py deleted file mode 100644 index 4ab96eb6..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/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 TestCasesTransport -from .grpc import TestCasesGrpcTransport -from .grpc_asyncio import TestCasesGrpcAsyncIOTransport -from .rest import TestCasesRestTransport -from .rest import TestCasesRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[TestCasesTransport]] -_transport_registry['grpc'] = TestCasesGrpcTransport -_transport_registry['grpc_asyncio'] = TestCasesGrpcAsyncIOTransport -_transport_registry['rest'] = TestCasesRestTransport - -__all__ = ( - 'TestCasesTransport', - 'TestCasesGrpcTransport', - 'TestCasesGrpcAsyncIOTransport', - 'TestCasesRestTransport', - 'TestCasesRestInterceptor', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/transports/base.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/transports/base.py deleted file mode 100644 index d44f3387..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/transports/base.py +++ /dev/null @@ -1,357 +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.dialogflowcx_v3 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.dialogflowcx_v3.types import test_case -from google.cloud.dialogflowcx_v3.types import test_case as gcdc_test_case -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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 TestCasesTransport(abc.ABC): - """Abstract transport class for TestCases.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/dialogflow', - ) - - DEFAULT_HOST: str = 'dialogflow.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.list_test_cases: gapic_v1.method.wrap_method( - self.list_test_cases, - default_timeout=None, - client_info=client_info, - ), - self.batch_delete_test_cases: gapic_v1.method.wrap_method( - self.batch_delete_test_cases, - default_timeout=None, - client_info=client_info, - ), - self.get_test_case: gapic_v1.method.wrap_method( - self.get_test_case, - default_timeout=None, - client_info=client_info, - ), - self.create_test_case: gapic_v1.method.wrap_method( - self.create_test_case, - default_timeout=None, - client_info=client_info, - ), - self.update_test_case: gapic_v1.method.wrap_method( - self.update_test_case, - default_timeout=None, - client_info=client_info, - ), - self.run_test_case: gapic_v1.method.wrap_method( - self.run_test_case, - default_timeout=None, - client_info=client_info, - ), - self.batch_run_test_cases: gapic_v1.method.wrap_method( - self.batch_run_test_cases, - default_timeout=None, - client_info=client_info, - ), - self.calculate_coverage: gapic_v1.method.wrap_method( - self.calculate_coverage, - default_timeout=None, - client_info=client_info, - ), - self.import_test_cases: gapic_v1.method.wrap_method( - self.import_test_cases, - default_timeout=None, - client_info=client_info, - ), - self.export_test_cases: gapic_v1.method.wrap_method( - self.export_test_cases, - default_timeout=None, - client_info=client_info, - ), - self.list_test_case_results: gapic_v1.method.wrap_method( - self.list_test_case_results, - default_timeout=None, - client_info=client_info, - ), - self.get_test_case_result: gapic_v1.method.wrap_method( - self.get_test_case_result, - 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 list_test_cases(self) -> Callable[ - [test_case.ListTestCasesRequest], - Union[ - test_case.ListTestCasesResponse, - Awaitable[test_case.ListTestCasesResponse] - ]]: - raise NotImplementedError() - - @property - def batch_delete_test_cases(self) -> Callable[ - [test_case.BatchDeleteTestCasesRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def get_test_case(self) -> Callable[ - [test_case.GetTestCaseRequest], - Union[ - test_case.TestCase, - Awaitable[test_case.TestCase] - ]]: - raise NotImplementedError() - - @property - def create_test_case(self) -> Callable[ - [gcdc_test_case.CreateTestCaseRequest], - Union[ - gcdc_test_case.TestCase, - Awaitable[gcdc_test_case.TestCase] - ]]: - raise NotImplementedError() - - @property - def update_test_case(self) -> Callable[ - [gcdc_test_case.UpdateTestCaseRequest], - Union[ - gcdc_test_case.TestCase, - Awaitable[gcdc_test_case.TestCase] - ]]: - raise NotImplementedError() - - @property - def run_test_case(self) -> Callable[ - [test_case.RunTestCaseRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def batch_run_test_cases(self) -> Callable[ - [test_case.BatchRunTestCasesRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def calculate_coverage(self) -> Callable[ - [test_case.CalculateCoverageRequest], - Union[ - test_case.CalculateCoverageResponse, - Awaitable[test_case.CalculateCoverageResponse] - ]]: - raise NotImplementedError() - - @property - def import_test_cases(self) -> Callable[ - [test_case.ImportTestCasesRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def export_test_cases(self) -> Callable[ - [test_case.ExportTestCasesRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_test_case_results(self) -> Callable[ - [test_case.ListTestCaseResultsRequest], - Union[ - test_case.ListTestCaseResultsResponse, - Awaitable[test_case.ListTestCaseResultsResponse] - ]]: - raise NotImplementedError() - - @property - def get_test_case_result(self) -> Callable[ - [test_case.GetTestCaseResultRequest], - Union[ - test_case.TestCaseResult, - Awaitable[test_case.TestCaseResult] - ]]: - 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 get_location(self, - ) -> Callable[ - [locations_pb2.GetLocationRequest], - Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], - ]: - raise NotImplementedError() - - @property - def list_locations(self, - ) -> Callable[ - [locations_pb2.ListLocationsRequest], - Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'TestCasesTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/transports/grpc.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/transports/grpc.py deleted file mode 100644 index d1c004fa..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/transports/grpc.py +++ /dev/null @@ -1,712 +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.dialogflowcx_v3.types import test_case -from google.cloud.dialogflowcx_v3.types import test_case as gcdc_test_case -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import TestCasesTransport, DEFAULT_CLIENT_INFO - - -class TestCasesGrpcTransport(TestCasesTransport): - """gRPC backend transport for TestCases. - - Service for managing [Test - Cases][google.cloud.dialogflow.cx.v3.TestCase] and [Test Case - Results][google.cloud.dialogflow.cx.v3.TestCaseResult]. - - 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 = 'dialogflow.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 = 'dialogflow.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 list_test_cases(self) -> Callable[ - [test_case.ListTestCasesRequest], - test_case.ListTestCasesResponse]: - r"""Return a callable for the list test cases method over gRPC. - - Fetches a list of test cases for a given agent. - - Returns: - Callable[[~.ListTestCasesRequest], - ~.ListTestCasesResponse]: - 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_test_cases' not in self._stubs: - self._stubs['list_test_cases'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/ListTestCases', - request_serializer=test_case.ListTestCasesRequest.serialize, - response_deserializer=test_case.ListTestCasesResponse.deserialize, - ) - return self._stubs['list_test_cases'] - - @property - def batch_delete_test_cases(self) -> Callable[ - [test_case.BatchDeleteTestCasesRequest], - empty_pb2.Empty]: - r"""Return a callable for the batch delete test cases method over gRPC. - - Batch deletes test cases. - - Returns: - Callable[[~.BatchDeleteTestCasesRequest], - ~.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 'batch_delete_test_cases' not in self._stubs: - self._stubs['batch_delete_test_cases'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/BatchDeleteTestCases', - request_serializer=test_case.BatchDeleteTestCasesRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['batch_delete_test_cases'] - - @property - def get_test_case(self) -> Callable[ - [test_case.GetTestCaseRequest], - test_case.TestCase]: - r"""Return a callable for the get test case method over gRPC. - - Gets a test case. - - Returns: - Callable[[~.GetTestCaseRequest], - ~.TestCase]: - 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_test_case' not in self._stubs: - self._stubs['get_test_case'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/GetTestCase', - request_serializer=test_case.GetTestCaseRequest.serialize, - response_deserializer=test_case.TestCase.deserialize, - ) - return self._stubs['get_test_case'] - - @property - def create_test_case(self) -> Callable[ - [gcdc_test_case.CreateTestCaseRequest], - gcdc_test_case.TestCase]: - r"""Return a callable for the create test case method over gRPC. - - Creates a test case for the given agent. - - Returns: - Callable[[~.CreateTestCaseRequest], - ~.TestCase]: - 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_test_case' not in self._stubs: - self._stubs['create_test_case'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/CreateTestCase', - request_serializer=gcdc_test_case.CreateTestCaseRequest.serialize, - response_deserializer=gcdc_test_case.TestCase.deserialize, - ) - return self._stubs['create_test_case'] - - @property - def update_test_case(self) -> Callable[ - [gcdc_test_case.UpdateTestCaseRequest], - gcdc_test_case.TestCase]: - r"""Return a callable for the update test case method over gRPC. - - Updates the specified test case. - - Returns: - Callable[[~.UpdateTestCaseRequest], - ~.TestCase]: - 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_test_case' not in self._stubs: - self._stubs['update_test_case'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/UpdateTestCase', - request_serializer=gcdc_test_case.UpdateTestCaseRequest.serialize, - response_deserializer=gcdc_test_case.TestCase.deserialize, - ) - return self._stubs['update_test_case'] - - @property - def run_test_case(self) -> Callable[ - [test_case.RunTestCaseRequest], - operations_pb2.Operation]: - r"""Return a callable for the run test case method over gRPC. - - Kicks off a test case run. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [RunTestCaseMetadata][google.cloud.dialogflow.cx.v3.RunTestCaseMetadata] - - ``response``: - [RunTestCaseResponse][google.cloud.dialogflow.cx.v3.RunTestCaseResponse] - - Returns: - Callable[[~.RunTestCaseRequest], - ~.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 'run_test_case' not in self._stubs: - self._stubs['run_test_case'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/RunTestCase', - request_serializer=test_case.RunTestCaseRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['run_test_case'] - - @property - def batch_run_test_cases(self) -> Callable[ - [test_case.BatchRunTestCasesRequest], - operations_pb2.Operation]: - r"""Return a callable for the batch run test cases method over gRPC. - - Kicks off a batch run of test cases. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [BatchRunTestCasesMetadata][google.cloud.dialogflow.cx.v3.BatchRunTestCasesMetadata] - - ``response``: - [BatchRunTestCasesResponse][google.cloud.dialogflow.cx.v3.BatchRunTestCasesResponse] - - Returns: - Callable[[~.BatchRunTestCasesRequest], - ~.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 'batch_run_test_cases' not in self._stubs: - self._stubs['batch_run_test_cases'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/BatchRunTestCases', - request_serializer=test_case.BatchRunTestCasesRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['batch_run_test_cases'] - - @property - def calculate_coverage(self) -> Callable[ - [test_case.CalculateCoverageRequest], - test_case.CalculateCoverageResponse]: - r"""Return a callable for the calculate coverage method over gRPC. - - Calculates the test coverage for an agent. - - Returns: - Callable[[~.CalculateCoverageRequest], - ~.CalculateCoverageResponse]: - 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_coverage' not in self._stubs: - self._stubs['calculate_coverage'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/CalculateCoverage', - request_serializer=test_case.CalculateCoverageRequest.serialize, - response_deserializer=test_case.CalculateCoverageResponse.deserialize, - ) - return self._stubs['calculate_coverage'] - - @property - def import_test_cases(self) -> Callable[ - [test_case.ImportTestCasesRequest], - operations_pb2.Operation]: - r"""Return a callable for the import test cases method over gRPC. - - Imports the test cases from a Cloud Storage bucket or a local - file. It always creates new test cases and won't overwrite any - existing ones. The provided ID in the imported test case is - neglected. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [ImportTestCasesMetadata][google.cloud.dialogflow.cx.v3.ImportTestCasesMetadata] - - ``response``: - [ImportTestCasesResponse][google.cloud.dialogflow.cx.v3.ImportTestCasesResponse] - - Returns: - Callable[[~.ImportTestCasesRequest], - ~.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 'import_test_cases' not in self._stubs: - self._stubs['import_test_cases'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/ImportTestCases', - request_serializer=test_case.ImportTestCasesRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['import_test_cases'] - - @property - def export_test_cases(self) -> Callable[ - [test_case.ExportTestCasesRequest], - operations_pb2.Operation]: - r"""Return a callable for the export test cases method over gRPC. - - Exports the test cases under the agent to a Cloud Storage bucket - or a local file. Filter can be applied to export a subset of - test cases. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [ExportTestCasesMetadata][google.cloud.dialogflow.cx.v3.ExportTestCasesMetadata] - - ``response``: - [ExportTestCasesResponse][google.cloud.dialogflow.cx.v3.ExportTestCasesResponse] - - Returns: - Callable[[~.ExportTestCasesRequest], - ~.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_test_cases' not in self._stubs: - self._stubs['export_test_cases'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/ExportTestCases', - request_serializer=test_case.ExportTestCasesRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['export_test_cases'] - - @property - def list_test_case_results(self) -> Callable[ - [test_case.ListTestCaseResultsRequest], - test_case.ListTestCaseResultsResponse]: - r"""Return a callable for the list test case results method over gRPC. - - Fetches the list of run results for the given test - case. A maximum of 100 results are kept for each test - case. - - Returns: - Callable[[~.ListTestCaseResultsRequest], - ~.ListTestCaseResultsResponse]: - 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_test_case_results' not in self._stubs: - self._stubs['list_test_case_results'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/ListTestCaseResults', - request_serializer=test_case.ListTestCaseResultsRequest.serialize, - response_deserializer=test_case.ListTestCaseResultsResponse.deserialize, - ) - return self._stubs['list_test_case_results'] - - @property - def get_test_case_result(self) -> Callable[ - [test_case.GetTestCaseResultRequest], - test_case.TestCaseResult]: - r"""Return a callable for the get test case result method over gRPC. - - Gets a test case result. - - Returns: - Callable[[~.GetTestCaseResultRequest], - ~.TestCaseResult]: - 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_test_case_result' not in self._stubs: - self._stubs['get_test_case_result'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/GetTestCaseResult', - request_serializer=test_case.GetTestCaseResultRequest.serialize, - response_deserializer=test_case.TestCaseResult.deserialize, - ) - return self._stubs['get_test_case_result'] - - 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 list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'TestCasesGrpcTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/transports/grpc_asyncio.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/transports/grpc_asyncio.py deleted file mode 100644 index 770aeaf0..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/transports/grpc_asyncio.py +++ /dev/null @@ -1,711 +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.dialogflowcx_v3.types import test_case -from google.cloud.dialogflowcx_v3.types import test_case as gcdc_test_case -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import TestCasesTransport, DEFAULT_CLIENT_INFO -from .grpc import TestCasesGrpcTransport - - -class TestCasesGrpcAsyncIOTransport(TestCasesTransport): - """gRPC AsyncIO backend transport for TestCases. - - Service for managing [Test - Cases][google.cloud.dialogflow.cx.v3.TestCase] and [Test Case - Results][google.cloud.dialogflow.cx.v3.TestCaseResult]. - - 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 = 'dialogflow.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 = 'dialogflow.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 list_test_cases(self) -> Callable[ - [test_case.ListTestCasesRequest], - Awaitable[test_case.ListTestCasesResponse]]: - r"""Return a callable for the list test cases method over gRPC. - - Fetches a list of test cases for a given agent. - - Returns: - Callable[[~.ListTestCasesRequest], - Awaitable[~.ListTestCasesResponse]]: - 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_test_cases' not in self._stubs: - self._stubs['list_test_cases'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/ListTestCases', - request_serializer=test_case.ListTestCasesRequest.serialize, - response_deserializer=test_case.ListTestCasesResponse.deserialize, - ) - return self._stubs['list_test_cases'] - - @property - def batch_delete_test_cases(self) -> Callable[ - [test_case.BatchDeleteTestCasesRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the batch delete test cases method over gRPC. - - Batch deletes test cases. - - Returns: - Callable[[~.BatchDeleteTestCasesRequest], - 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 'batch_delete_test_cases' not in self._stubs: - self._stubs['batch_delete_test_cases'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/BatchDeleteTestCases', - request_serializer=test_case.BatchDeleteTestCasesRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['batch_delete_test_cases'] - - @property - def get_test_case(self) -> Callable[ - [test_case.GetTestCaseRequest], - Awaitable[test_case.TestCase]]: - r"""Return a callable for the get test case method over gRPC. - - Gets a test case. - - Returns: - Callable[[~.GetTestCaseRequest], - Awaitable[~.TestCase]]: - 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_test_case' not in self._stubs: - self._stubs['get_test_case'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/GetTestCase', - request_serializer=test_case.GetTestCaseRequest.serialize, - response_deserializer=test_case.TestCase.deserialize, - ) - return self._stubs['get_test_case'] - - @property - def create_test_case(self) -> Callable[ - [gcdc_test_case.CreateTestCaseRequest], - Awaitable[gcdc_test_case.TestCase]]: - r"""Return a callable for the create test case method over gRPC. - - Creates a test case for the given agent. - - Returns: - Callable[[~.CreateTestCaseRequest], - Awaitable[~.TestCase]]: - 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_test_case' not in self._stubs: - self._stubs['create_test_case'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/CreateTestCase', - request_serializer=gcdc_test_case.CreateTestCaseRequest.serialize, - response_deserializer=gcdc_test_case.TestCase.deserialize, - ) - return self._stubs['create_test_case'] - - @property - def update_test_case(self) -> Callable[ - [gcdc_test_case.UpdateTestCaseRequest], - Awaitable[gcdc_test_case.TestCase]]: - r"""Return a callable for the update test case method over gRPC. - - Updates the specified test case. - - Returns: - Callable[[~.UpdateTestCaseRequest], - Awaitable[~.TestCase]]: - 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_test_case' not in self._stubs: - self._stubs['update_test_case'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/UpdateTestCase', - request_serializer=gcdc_test_case.UpdateTestCaseRequest.serialize, - response_deserializer=gcdc_test_case.TestCase.deserialize, - ) - return self._stubs['update_test_case'] - - @property - def run_test_case(self) -> Callable[ - [test_case.RunTestCaseRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the run test case method over gRPC. - - Kicks off a test case run. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [RunTestCaseMetadata][google.cloud.dialogflow.cx.v3.RunTestCaseMetadata] - - ``response``: - [RunTestCaseResponse][google.cloud.dialogflow.cx.v3.RunTestCaseResponse] - - Returns: - Callable[[~.RunTestCaseRequest], - 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 'run_test_case' not in self._stubs: - self._stubs['run_test_case'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/RunTestCase', - request_serializer=test_case.RunTestCaseRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['run_test_case'] - - @property - def batch_run_test_cases(self) -> Callable[ - [test_case.BatchRunTestCasesRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the batch run test cases method over gRPC. - - Kicks off a batch run of test cases. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [BatchRunTestCasesMetadata][google.cloud.dialogflow.cx.v3.BatchRunTestCasesMetadata] - - ``response``: - [BatchRunTestCasesResponse][google.cloud.dialogflow.cx.v3.BatchRunTestCasesResponse] - - Returns: - Callable[[~.BatchRunTestCasesRequest], - 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 'batch_run_test_cases' not in self._stubs: - self._stubs['batch_run_test_cases'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/BatchRunTestCases', - request_serializer=test_case.BatchRunTestCasesRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['batch_run_test_cases'] - - @property - def calculate_coverage(self) -> Callable[ - [test_case.CalculateCoverageRequest], - Awaitable[test_case.CalculateCoverageResponse]]: - r"""Return a callable for the calculate coverage method over gRPC. - - Calculates the test coverage for an agent. - - Returns: - Callable[[~.CalculateCoverageRequest], - Awaitable[~.CalculateCoverageResponse]]: - 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_coverage' not in self._stubs: - self._stubs['calculate_coverage'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/CalculateCoverage', - request_serializer=test_case.CalculateCoverageRequest.serialize, - response_deserializer=test_case.CalculateCoverageResponse.deserialize, - ) - return self._stubs['calculate_coverage'] - - @property - def import_test_cases(self) -> Callable[ - [test_case.ImportTestCasesRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the import test cases method over gRPC. - - Imports the test cases from a Cloud Storage bucket or a local - file. It always creates new test cases and won't overwrite any - existing ones. The provided ID in the imported test case is - neglected. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [ImportTestCasesMetadata][google.cloud.dialogflow.cx.v3.ImportTestCasesMetadata] - - ``response``: - [ImportTestCasesResponse][google.cloud.dialogflow.cx.v3.ImportTestCasesResponse] - - Returns: - Callable[[~.ImportTestCasesRequest], - 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 'import_test_cases' not in self._stubs: - self._stubs['import_test_cases'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/ImportTestCases', - request_serializer=test_case.ImportTestCasesRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['import_test_cases'] - - @property - def export_test_cases(self) -> Callable[ - [test_case.ExportTestCasesRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the export test cases method over gRPC. - - Exports the test cases under the agent to a Cloud Storage bucket - or a local file. Filter can be applied to export a subset of - test cases. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [ExportTestCasesMetadata][google.cloud.dialogflow.cx.v3.ExportTestCasesMetadata] - - ``response``: - [ExportTestCasesResponse][google.cloud.dialogflow.cx.v3.ExportTestCasesResponse] - - Returns: - Callable[[~.ExportTestCasesRequest], - 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_test_cases' not in self._stubs: - self._stubs['export_test_cases'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/ExportTestCases', - request_serializer=test_case.ExportTestCasesRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['export_test_cases'] - - @property - def list_test_case_results(self) -> Callable[ - [test_case.ListTestCaseResultsRequest], - Awaitable[test_case.ListTestCaseResultsResponse]]: - r"""Return a callable for the list test case results method over gRPC. - - Fetches the list of run results for the given test - case. A maximum of 100 results are kept for each test - case. - - Returns: - Callable[[~.ListTestCaseResultsRequest], - Awaitable[~.ListTestCaseResultsResponse]]: - 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_test_case_results' not in self._stubs: - self._stubs['list_test_case_results'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/ListTestCaseResults', - request_serializer=test_case.ListTestCaseResultsRequest.serialize, - response_deserializer=test_case.ListTestCaseResultsResponse.deserialize, - ) - return self._stubs['list_test_case_results'] - - @property - def get_test_case_result(self) -> Callable[ - [test_case.GetTestCaseResultRequest], - Awaitable[test_case.TestCaseResult]]: - r"""Return a callable for the get test case result method over gRPC. - - Gets a test case result. - - Returns: - Callable[[~.GetTestCaseResultRequest], - Awaitable[~.TestCaseResult]]: - 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_test_case_result' not in self._stubs: - self._stubs['get_test_case_result'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TestCases/GetTestCaseResult', - request_serializer=test_case.GetTestCaseResultRequest.serialize, - response_deserializer=test_case.TestCaseResult.deserialize, - ) - return self._stubs['get_test_case_result'] - - 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"] - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - -__all__ = ( - 'TestCasesGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/transports/rest.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/transports/rest.py deleted file mode 100644 index 121ddf71..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/test_cases/transports/rest.py +++ /dev/null @@ -1,2057 +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 google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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.dialogflowcx_v3.types import test_case -from google.cloud.dialogflowcx_v3.types import test_case as gcdc_test_case -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore - -from .base import TestCasesTransport, 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 TestCasesRestInterceptor: - """Interceptor for TestCases. - - 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 TestCasesRestTransport. - - .. code-block:: python - class MyCustomTestCasesInterceptor(TestCasesRestInterceptor): - def pre_batch_delete_test_cases(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_batch_run_test_cases(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_batch_run_test_cases(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_calculate_coverage(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_calculate_coverage(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_test_case(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_test_case(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_export_test_cases(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_export_test_cases(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_test_case(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_test_case(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_test_case_result(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_test_case_result(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_import_test_cases(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_import_test_cases(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_test_case_results(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_test_case_results(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_test_cases(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_test_cases(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_run_test_case(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_run_test_case(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_test_case(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_test_case(self, response): - logging.log(f"Received response: {response}") - return response - - transport = TestCasesRestTransport(interceptor=MyCustomTestCasesInterceptor()) - client = TestCasesClient(transport=transport) - - - """ - def pre_batch_delete_test_cases(self, request: test_case.BatchDeleteTestCasesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[test_case.BatchDeleteTestCasesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for batch_delete_test_cases - - Override in a subclass to manipulate the request or metadata - before they are sent to the TestCases server. - """ - return request, metadata - - def pre_batch_run_test_cases(self, request: test_case.BatchRunTestCasesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[test_case.BatchRunTestCasesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for batch_run_test_cases - - Override in a subclass to manipulate the request or metadata - before they are sent to the TestCases server. - """ - return request, metadata - - def post_batch_run_test_cases(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for batch_run_test_cases - - Override in a subclass to manipulate the response - after it is returned by the TestCases server but before - it is returned to user code. - """ - return response - def pre_calculate_coverage(self, request: test_case.CalculateCoverageRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[test_case.CalculateCoverageRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for calculate_coverage - - Override in a subclass to manipulate the request or metadata - before they are sent to the TestCases server. - """ - return request, metadata - - def post_calculate_coverage(self, response: test_case.CalculateCoverageResponse) -> test_case.CalculateCoverageResponse: - """Post-rpc interceptor for calculate_coverage - - Override in a subclass to manipulate the response - after it is returned by the TestCases server but before - it is returned to user code. - """ - return response - def pre_create_test_case(self, request: gcdc_test_case.CreateTestCaseRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_test_case.CreateTestCaseRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_test_case - - Override in a subclass to manipulate the request or metadata - before they are sent to the TestCases server. - """ - return request, metadata - - def post_create_test_case(self, response: gcdc_test_case.TestCase) -> gcdc_test_case.TestCase: - """Post-rpc interceptor for create_test_case - - Override in a subclass to manipulate the response - after it is returned by the TestCases server but before - it is returned to user code. - """ - return response - def pre_export_test_cases(self, request: test_case.ExportTestCasesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[test_case.ExportTestCasesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for export_test_cases - - Override in a subclass to manipulate the request or metadata - before they are sent to the TestCases server. - """ - return request, metadata - - def post_export_test_cases(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for export_test_cases - - Override in a subclass to manipulate the response - after it is returned by the TestCases server but before - it is returned to user code. - """ - return response - def pre_get_test_case(self, request: test_case.GetTestCaseRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[test_case.GetTestCaseRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_test_case - - Override in a subclass to manipulate the request or metadata - before they are sent to the TestCases server. - """ - return request, metadata - - def post_get_test_case(self, response: test_case.TestCase) -> test_case.TestCase: - """Post-rpc interceptor for get_test_case - - Override in a subclass to manipulate the response - after it is returned by the TestCases server but before - it is returned to user code. - """ - return response - def pre_get_test_case_result(self, request: test_case.GetTestCaseResultRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[test_case.GetTestCaseResultRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_test_case_result - - Override in a subclass to manipulate the request or metadata - before they are sent to the TestCases server. - """ - return request, metadata - - def post_get_test_case_result(self, response: test_case.TestCaseResult) -> test_case.TestCaseResult: - """Post-rpc interceptor for get_test_case_result - - Override in a subclass to manipulate the response - after it is returned by the TestCases server but before - it is returned to user code. - """ - return response - def pre_import_test_cases(self, request: test_case.ImportTestCasesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[test_case.ImportTestCasesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for import_test_cases - - Override in a subclass to manipulate the request or metadata - before they are sent to the TestCases server. - """ - return request, metadata - - def post_import_test_cases(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for import_test_cases - - Override in a subclass to manipulate the response - after it is returned by the TestCases server but before - it is returned to user code. - """ - return response - def pre_list_test_case_results(self, request: test_case.ListTestCaseResultsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[test_case.ListTestCaseResultsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_test_case_results - - Override in a subclass to manipulate the request or metadata - before they are sent to the TestCases server. - """ - return request, metadata - - def post_list_test_case_results(self, response: test_case.ListTestCaseResultsResponse) -> test_case.ListTestCaseResultsResponse: - """Post-rpc interceptor for list_test_case_results - - Override in a subclass to manipulate the response - after it is returned by the TestCases server but before - it is returned to user code. - """ - return response - def pre_list_test_cases(self, request: test_case.ListTestCasesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[test_case.ListTestCasesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_test_cases - - Override in a subclass to manipulate the request or metadata - before they are sent to the TestCases server. - """ - return request, metadata - - def post_list_test_cases(self, response: test_case.ListTestCasesResponse) -> test_case.ListTestCasesResponse: - """Post-rpc interceptor for list_test_cases - - Override in a subclass to manipulate the response - after it is returned by the TestCases server but before - it is returned to user code. - """ - return response - def pre_run_test_case(self, request: test_case.RunTestCaseRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[test_case.RunTestCaseRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for run_test_case - - Override in a subclass to manipulate the request or metadata - before they are sent to the TestCases server. - """ - return request, metadata - - def post_run_test_case(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for run_test_case - - Override in a subclass to manipulate the response - after it is returned by the TestCases server but before - it is returned to user code. - """ - return response - def pre_update_test_case(self, request: gcdc_test_case.UpdateTestCaseRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_test_case.UpdateTestCaseRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_test_case - - Override in a subclass to manipulate the request or metadata - before they are sent to the TestCases server. - """ - return request, metadata - - def post_update_test_case(self, response: gcdc_test_case.TestCase) -> gcdc_test_case.TestCase: - """Post-rpc interceptor for update_test_case - - Override in a subclass to manipulate the response - after it is returned by the TestCases server but before - it is returned to user code. - """ - return response - - def pre_get_location( - self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_location - - Override in a subclass to manipulate the request or metadata - before they are sent to the TestCases server. - """ - return request, metadata - - def post_get_location( - self, response: locations_pb2.Location - ) -> locations_pb2.Location: - """Post-rpc interceptor for get_location - - Override in a subclass to manipulate the response - after it is returned by the TestCases server but before - it is returned to user code. - """ - return response - def pre_list_locations( - self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_locations - - Override in a subclass to manipulate the request or metadata - before they are sent to the TestCases server. - """ - return request, metadata - - def post_list_locations( - self, response: locations_pb2.ListLocationsResponse - ) -> locations_pb2.ListLocationsResponse: - """Post-rpc interceptor for list_locations - - Override in a subclass to manipulate the response - after it is returned by the TestCases 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 TestCases 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 TestCases 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 TestCases 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 TestCases 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 TestCases 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 TestCases server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class TestCasesRestStub: - _session: AuthorizedSession - _host: str - _interceptor: TestCasesRestInterceptor - - -class TestCasesRestTransport(TestCasesTransport): - """REST backend transport for TestCases. - - Service for managing [Test - Cases][google.cloud.dialogflow.cx.v3.TestCase] and [Test Case - Results][google.cloud.dialogflow.cx.v3.TestCaseResult]. - - 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 = 'dialogflow.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[TestCasesRestInterceptor] = 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 TestCasesRestInterceptor() - 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': '/v3/{name=projects/*/operations/*}:cancel', - }, - { - 'method': 'post', - 'uri': '/v3/{name=projects/*/locations/*/operations/*}:cancel', - }, - ], - 'google.longrunning.Operations.GetOperation': [ - { - 'method': 'get', - 'uri': '/v3/{name=projects/*/operations/*}', - }, - { - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/operations/*}', - }, - ], - 'google.longrunning.Operations.ListOperations': [ - { - 'method': 'get', - 'uri': '/v3/{name=projects/*}/operations', - }, - { - 'method': 'get', - 'uri': '/v3/{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="v3") - - self._operations_client = operations_v1.AbstractOperationsClient(transport=rest_transport) - - # Return the client from cache. - return self._operations_client - - class _BatchDeleteTestCases(TestCasesRestStub): - def __hash__(self): - return hash("BatchDeleteTestCases") - - __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: test_case.BatchDeleteTestCasesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the batch delete test cases method over HTTP. - - Args: - request (~.test_case.BatchDeleteTestCasesRequest): - The request object. The request message for - [TestCases.BatchDeleteTestCases][google.cloud.dialogflow.cx.v3.TestCases.BatchDeleteTestCases]. - 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': '/v3/{parent=projects/*/locations/*/agents/*}/testCases:batchDelete', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_batch_delete_test_cases(request, metadata) - pb_request = test_case.BatchDeleteTestCasesRequest.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) - - class _BatchRunTestCases(TestCasesRestStub): - def __hash__(self): - return hash("BatchRunTestCases") - - __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: test_case.BatchRunTestCasesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the batch run test cases method over HTTP. - - Args: - request (~.test_case.BatchRunTestCasesRequest): - The request object. The request message for - [TestCases.BatchRunTestCases][google.cloud.dialogflow.cx.v3.TestCases.BatchRunTestCases]. - 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': '/v3/{parent=projects/*/locations/*/agents/*}/testCases:batchRun', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_batch_run_test_cases(request, metadata) - pb_request = test_case.BatchRunTestCasesRequest.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_batch_run_test_cases(resp) - return resp - - class _CalculateCoverage(TestCasesRestStub): - def __hash__(self): - return hash("CalculateCoverage") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "type" : {}, } - - @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: test_case.CalculateCoverageRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> test_case.CalculateCoverageResponse: - r"""Call the calculate coverage method over HTTP. - - Args: - request (~.test_case.CalculateCoverageRequest): - The request object. The request message for - [TestCases.CalculateCoverage][google.cloud.dialogflow.cx.v3.TestCases.CalculateCoverage]. - 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: - ~.test_case.CalculateCoverageResponse: - The response message for - [TestCases.CalculateCoverage][google.cloud.dialogflow.cx.v3.TestCases.CalculateCoverage]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{agent=projects/*/locations/*/agents/*}/testCases:calculateCoverage', - }, - ] - request, metadata = self._interceptor.pre_calculate_coverage(request, metadata) - pb_request = test_case.CalculateCoverageRequest.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 = test_case.CalculateCoverageResponse() - pb_resp = test_case.CalculateCoverageResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_calculate_coverage(resp) - return resp - - class _CreateTestCase(TestCasesRestStub): - def __hash__(self): - return hash("CreateTestCase") - - __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: gcdc_test_case.CreateTestCaseRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_test_case.TestCase: - r"""Call the create test case method over HTTP. - - Args: - request (~.gcdc_test_case.CreateTestCaseRequest): - The request object. The request message for - [TestCases.CreateTestCase][google.cloud.dialogflow.cx.v3.TestCases.CreateTestCase]. - 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: - ~.gcdc_test_case.TestCase: - Represents a test case. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*}/testCases', - 'body': 'test_case', - }, - ] - request, metadata = self._interceptor.pre_create_test_case(request, metadata) - pb_request = gcdc_test_case.CreateTestCaseRequest.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 = gcdc_test_case.TestCase() - pb_resp = gcdc_test_case.TestCase.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_test_case(resp) - return resp - - class _ExportTestCases(TestCasesRestStub): - def __hash__(self): - return hash("ExportTestCases") - - __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: test_case.ExportTestCasesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the export test cases method over HTTP. - - Args: - request (~.test_case.ExportTestCasesRequest): - The request object. The request message for - [TestCases.ExportTestCases][google.cloud.dialogflow.cx.v3.TestCases.ExportTestCases]. - 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': '/v3/{parent=projects/*/locations/*/agents/*}/testCases:export', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_export_test_cases(request, metadata) - pb_request = test_case.ExportTestCasesRequest.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_test_cases(resp) - return resp - - class _GetTestCase(TestCasesRestStub): - def __hash__(self): - return hash("GetTestCase") - - __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: test_case.GetTestCaseRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> test_case.TestCase: - r"""Call the get test case method over HTTP. - - Args: - request (~.test_case.GetTestCaseRequest): - The request object. The request message for - [TestCases.GetTestCase][google.cloud.dialogflow.cx.v3.TestCases.GetTestCase]. - 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: - ~.test_case.TestCase: - Represents a test case. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/testCases/*}', - }, - ] - request, metadata = self._interceptor.pre_get_test_case(request, metadata) - pb_request = test_case.GetTestCaseRequest.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 = test_case.TestCase() - pb_resp = test_case.TestCase.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_test_case(resp) - return resp - - class _GetTestCaseResult(TestCasesRestStub): - def __hash__(self): - return hash("GetTestCaseResult") - - __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: test_case.GetTestCaseResultRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> test_case.TestCaseResult: - r"""Call the get test case result method over HTTP. - - Args: - request (~.test_case.GetTestCaseResultRequest): - The request object. The request message for - [TestCases.GetTestCaseResult][google.cloud.dialogflow.cx.v3.TestCases.GetTestCaseResult]. - 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: - ~.test_case.TestCaseResult: - Represents a result from running a - test case in an agent environment. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/testCases/*/results/*}', - }, - ] - request, metadata = self._interceptor.pre_get_test_case_result(request, metadata) - pb_request = test_case.GetTestCaseResultRequest.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 = test_case.TestCaseResult() - pb_resp = test_case.TestCaseResult.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_test_case_result(resp) - return resp - - class _ImportTestCases(TestCasesRestStub): - def __hash__(self): - return hash("ImportTestCases") - - __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: test_case.ImportTestCasesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the import test cases method over HTTP. - - Args: - request (~.test_case.ImportTestCasesRequest): - The request object. The request message for - [TestCases.ImportTestCases][google.cloud.dialogflow.cx.v3.TestCases.ImportTestCases]. - 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': '/v3/{parent=projects/*/locations/*/agents/*}/testCases:import', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_import_test_cases(request, metadata) - pb_request = test_case.ImportTestCasesRequest.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_import_test_cases(resp) - return resp - - class _ListTestCaseResults(TestCasesRestStub): - def __hash__(self): - return hash("ListTestCaseResults") - - __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: test_case.ListTestCaseResultsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> test_case.ListTestCaseResultsResponse: - r"""Call the list test case results method over HTTP. - - Args: - request (~.test_case.ListTestCaseResultsRequest): - The request object. The request message for - [TestCases.ListTestCaseResults][google.cloud.dialogflow.cx.v3.TestCases.ListTestCaseResults]. - 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: - ~.test_case.ListTestCaseResultsResponse: - The response message for - [TestCases.ListTestCaseResults][google.cloud.dialogflow.cx.v3.TestCases.ListTestCaseResults]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*/testCases/*}/results', - }, - ] - request, metadata = self._interceptor.pre_list_test_case_results(request, metadata) - pb_request = test_case.ListTestCaseResultsRequest.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 = test_case.ListTestCaseResultsResponse() - pb_resp = test_case.ListTestCaseResultsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_test_case_results(resp) - return resp - - class _ListTestCases(TestCasesRestStub): - def __hash__(self): - return hash("ListTestCases") - - __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: test_case.ListTestCasesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> test_case.ListTestCasesResponse: - r"""Call the list test cases method over HTTP. - - Args: - request (~.test_case.ListTestCasesRequest): - The request object. The request message for - [TestCases.ListTestCases][google.cloud.dialogflow.cx.v3.TestCases.ListTestCases]. - 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: - ~.test_case.ListTestCasesResponse: - The response message for - [TestCases.ListTestCases][google.cloud.dialogflow.cx.v3.TestCases.ListTestCases]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*}/testCases', - }, - ] - request, metadata = self._interceptor.pre_list_test_cases(request, metadata) - pb_request = test_case.ListTestCasesRequest.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 = test_case.ListTestCasesResponse() - pb_resp = test_case.ListTestCasesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_test_cases(resp) - return resp - - class _RunTestCase(TestCasesRestStub): - def __hash__(self): - return hash("RunTestCase") - - __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: test_case.RunTestCaseRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the run test case method over HTTP. - - Args: - request (~.test_case.RunTestCaseRequest): - The request object. The request message for - [TestCases.RunTestCase][google.cloud.dialogflow.cx.v3.TestCases.RunTestCase]. - 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': '/v3/{name=projects/*/locations/*/agents/*/testCases/*}:run', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_run_test_case(request, metadata) - pb_request = test_case.RunTestCaseRequest.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_run_test_case(resp) - return resp - - class _UpdateTestCase(TestCasesRestStub): - def __hash__(self): - return hash("UpdateTestCase") - - __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: gcdc_test_case.UpdateTestCaseRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_test_case.TestCase: - r"""Call the update test case method over HTTP. - - Args: - request (~.gcdc_test_case.UpdateTestCaseRequest): - The request object. The request message for - [TestCases.UpdateTestCase][google.cloud.dialogflow.cx.v3.TestCases.UpdateTestCase]. - 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: - ~.gcdc_test_case.TestCase: - Represents a test case. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v3/{test_case.name=projects/*/locations/*/agents/*/testCases/*}', - 'body': 'test_case', - }, - ] - request, metadata = self._interceptor.pre_update_test_case(request, metadata) - pb_request = gcdc_test_case.UpdateTestCaseRequest.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 = gcdc_test_case.TestCase() - pb_resp = gcdc_test_case.TestCase.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_test_case(resp) - return resp - - @property - def batch_delete_test_cases(self) -> Callable[ - [test_case.BatchDeleteTestCasesRequest], - 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._BatchDeleteTestCases(self._session, self._host, self._interceptor) # type: ignore - - @property - def batch_run_test_cases(self) -> Callable[ - [test_case.BatchRunTestCasesRequest], - 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._BatchRunTestCases(self._session, self._host, self._interceptor) # type: ignore - - @property - def calculate_coverage(self) -> Callable[ - [test_case.CalculateCoverageRequest], - test_case.CalculateCoverageResponse]: - # 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._CalculateCoverage(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_test_case(self) -> Callable[ - [gcdc_test_case.CreateTestCaseRequest], - gcdc_test_case.TestCase]: - # 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._CreateTestCase(self._session, self._host, self._interceptor) # type: ignore - - @property - def export_test_cases(self) -> Callable[ - [test_case.ExportTestCasesRequest], - 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._ExportTestCases(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_test_case(self) -> Callable[ - [test_case.GetTestCaseRequest], - test_case.TestCase]: - # 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._GetTestCase(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_test_case_result(self) -> Callable[ - [test_case.GetTestCaseResultRequest], - test_case.TestCaseResult]: - # 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._GetTestCaseResult(self._session, self._host, self._interceptor) # type: ignore - - @property - def import_test_cases(self) -> Callable[ - [test_case.ImportTestCasesRequest], - 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._ImportTestCases(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_test_case_results(self) -> Callable[ - [test_case.ListTestCaseResultsRequest], - test_case.ListTestCaseResultsResponse]: - # 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._ListTestCaseResults(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_test_cases(self) -> Callable[ - [test_case.ListTestCasesRequest], - test_case.ListTestCasesResponse]: - # 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._ListTestCases(self._session, self._host, self._interceptor) # type: ignore - - @property - def run_test_case(self) -> Callable[ - [test_case.RunTestCaseRequest], - 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._RunTestCase(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_test_case(self) -> Callable[ - [gcdc_test_case.UpdateTestCaseRequest], - gcdc_test_case.TestCase]: - # 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._UpdateTestCase(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_location(self): - return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore - - class _GetLocation(TestCasesRestStub): - def __call__(self, - request: locations_pb2.GetLocationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.Location: - - r"""Call the get location method over HTTP. - - Args: - request (locations_pb2.GetLocationRequest): - The request object for GetLocation 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: - locations_pb2.Location: Response from GetLocation method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*}', - }, - ] - - request, metadata = self._interceptor.pre_get_location(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 = locations_pb2.Location() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_get_location(resp) - return resp - - @property - def list_locations(self): - return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore - - class _ListLocations(TestCasesRestStub): - def __call__(self, - request: locations_pb2.ListLocationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.ListLocationsResponse: - - r"""Call the list locations method over HTTP. - - Args: - request (locations_pb2.ListLocationsRequest): - The request object for ListLocations 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: - locations_pb2.ListLocationsResponse: Response from ListLocations method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*}/locations', - }, - ] - - request, metadata = self._interceptor.pre_list_locations(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 = locations_pb2.ListLocationsResponse() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_list_locations(resp) - return resp - - @property - def cancel_operation(self): - return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore - - class _CancelOperation(TestCasesRestStub): - 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': '/v3/{name=projects/*/operations/*}:cancel', - }, -{ - 'method': 'post', - 'uri': '/v3/{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(TestCasesRestStub): - 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': '/v3/{name=projects/*/operations/*}', - }, -{ - 'method': 'get', - 'uri': '/v3/{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(TestCasesRestStub): - 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': '/v3/{name=projects/*}/operations', - }, -{ - 'method': 'get', - 'uri': '/v3/{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__=( - 'TestCasesRestTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/__init__.py deleted file mode 100644 index 2cba8023..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/__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 TransitionRouteGroupsClient -from .async_client import TransitionRouteGroupsAsyncClient - -__all__ = ( - 'TransitionRouteGroupsClient', - 'TransitionRouteGroupsAsyncClient', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/async_client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/async_client.py deleted file mode 100644 index fd1e3424..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/async_client.py +++ /dev/null @@ -1,1039 +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.dialogflowcx_v3 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.cloud.dialogflowcx_v3.services.transition_route_groups import pagers -from google.cloud.dialogflowcx_v3.types import page -from google.cloud.dialogflowcx_v3.types import transition_route_group -from google.cloud.dialogflowcx_v3.types import transition_route_group as gcdc_transition_route_group -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import TransitionRouteGroupsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import TransitionRouteGroupsGrpcAsyncIOTransport -from .client import TransitionRouteGroupsClient - - -class TransitionRouteGroupsAsyncClient: - """Service for managing - [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - """ - - _client: TransitionRouteGroupsClient - - DEFAULT_ENDPOINT = TransitionRouteGroupsClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = TransitionRouteGroupsClient.DEFAULT_MTLS_ENDPOINT - - flow_path = staticmethod(TransitionRouteGroupsClient.flow_path) - parse_flow_path = staticmethod(TransitionRouteGroupsClient.parse_flow_path) - intent_path = staticmethod(TransitionRouteGroupsClient.intent_path) - parse_intent_path = staticmethod(TransitionRouteGroupsClient.parse_intent_path) - page_path = staticmethod(TransitionRouteGroupsClient.page_path) - parse_page_path = staticmethod(TransitionRouteGroupsClient.parse_page_path) - transition_route_group_path = staticmethod(TransitionRouteGroupsClient.transition_route_group_path) - parse_transition_route_group_path = staticmethod(TransitionRouteGroupsClient.parse_transition_route_group_path) - webhook_path = staticmethod(TransitionRouteGroupsClient.webhook_path) - parse_webhook_path = staticmethod(TransitionRouteGroupsClient.parse_webhook_path) - common_billing_account_path = staticmethod(TransitionRouteGroupsClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(TransitionRouteGroupsClient.parse_common_billing_account_path) - common_folder_path = staticmethod(TransitionRouteGroupsClient.common_folder_path) - parse_common_folder_path = staticmethod(TransitionRouteGroupsClient.parse_common_folder_path) - common_organization_path = staticmethod(TransitionRouteGroupsClient.common_organization_path) - parse_common_organization_path = staticmethod(TransitionRouteGroupsClient.parse_common_organization_path) - common_project_path = staticmethod(TransitionRouteGroupsClient.common_project_path) - parse_common_project_path = staticmethod(TransitionRouteGroupsClient.parse_common_project_path) - common_location_path = staticmethod(TransitionRouteGroupsClient.common_location_path) - parse_common_location_path = staticmethod(TransitionRouteGroupsClient.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: - TransitionRouteGroupsAsyncClient: The constructed client. - """ - return TransitionRouteGroupsClient.from_service_account_info.__func__(TransitionRouteGroupsAsyncClient, 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: - TransitionRouteGroupsAsyncClient: The constructed client. - """ - return TransitionRouteGroupsClient.from_service_account_file.__func__(TransitionRouteGroupsAsyncClient, 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 TransitionRouteGroupsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> TransitionRouteGroupsTransport: - """Returns the transport used by the client instance. - - Returns: - TransitionRouteGroupsTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(TransitionRouteGroupsClient).get_transport_class, type(TransitionRouteGroupsClient)) - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, TransitionRouteGroupsTransport] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the transition route groups 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, ~.TransitionRouteGroupsTransport]): 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 = TransitionRouteGroupsClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def list_transition_route_groups(self, - request: Optional[Union[transition_route_group.ListTransitionRouteGroupsRequest, 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.ListTransitionRouteGroupsAsyncPager: - r"""Returns the list of all transition route groups in - the specified flow. - - .. 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 dialogflowcx_v3 - - async def sample_list_transition_route_groups(): - # Create a client - client = dialogflowcx_v3.TransitionRouteGroupsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListTransitionRouteGroupsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_transition_route_groups(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ListTransitionRouteGroupsRequest, dict]]): - The request object. The request message for - [TransitionRouteGroups.ListTransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroups.ListTransitionRouteGroups]. - parent (:class:`str`): - Required. The flow to list all transition route groups - for. Format: - ``projects//locations//agents//flows/`` - or \`projects//locations//agents/. - - 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.dialogflowcx_v3.services.transition_route_groups.pagers.ListTransitionRouteGroupsAsyncPager: - The response message for - [TransitionRouteGroups.ListTransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroups.ListTransitionRouteGroups]. - - 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 = transition_route_group.ListTransitionRouteGroupsRequest(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_transition_route_groups, - 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.ListTransitionRouteGroupsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_transition_route_group(self, - request: Optional[Union[transition_route_group.GetTransitionRouteGroupRequest, 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]] = (), - ) -> transition_route_group.TransitionRouteGroup: - r"""Retrieves the specified - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - - .. 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 dialogflowcx_v3 - - async def sample_get_transition_route_group(): - # Create a client - client = dialogflowcx_v3.TransitionRouteGroupsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetTransitionRouteGroupRequest( - name="name_value", - ) - - # Make the request - response = await client.get_transition_route_group(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.GetTransitionRouteGroupRequest, dict]]): - The request object. The request message for - [TransitionRouteGroups.GetTransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroups.GetTransitionRouteGroup]. - name (:class:`str`): - Required. The name of the - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - Format: - ``projects//locations//agents//flows//transitionRouteGroups/`` - or - ``projects//locations//agents//transitionRouteGroups/``. - - 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.dialogflowcx_v3.types.TransitionRouteGroup: - A TransitionRouteGroup represents a group of - [TransitionRoutes][google.cloud.dialogflow.cx.v3.TransitionRoute] - to be used by a - [Page][google.cloud.dialogflow.cx.v3.Page]. - - """ - # 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 = transition_route_group.GetTransitionRouteGroupRequest(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_transition_route_group, - 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 create_transition_route_group(self, - request: Optional[Union[gcdc_transition_route_group.CreateTransitionRouteGroupRequest, dict]] = None, - *, - parent: Optional[str] = None, - transition_route_group: Optional[gcdc_transition_route_group.TransitionRouteGroup] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_transition_route_group.TransitionRouteGroup: - r"""Creates an - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - in the specified flow. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - async def sample_create_transition_route_group(): - # Create a client - client = dialogflowcx_v3.TransitionRouteGroupsAsyncClient() - - # Initialize request argument(s) - transition_route_group = dialogflowcx_v3.TransitionRouteGroup() - transition_route_group.display_name = "display_name_value" - - request = dialogflowcx_v3.CreateTransitionRouteGroupRequest( - parent="parent_value", - transition_route_group=transition_route_group, - ) - - # Make the request - response = await client.create_transition_route_group(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.CreateTransitionRouteGroupRequest, dict]]): - The request object. The request message for - [TransitionRouteGroups.CreateTransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroups.CreateTransitionRouteGroup]. - parent (:class:`str`): - Required. The flow to create an - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - for. Format: - ``projects//locations//agents//flows/`` - or - ``projects//locations//agents/`` - for agent-level groups. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - transition_route_group (:class:`google.cloud.dialogflowcx_v3.types.TransitionRouteGroup`): - Required. The transition route group - to create. - - This corresponds to the ``transition_route_group`` 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.dialogflowcx_v3.types.TransitionRouteGroup: - A TransitionRouteGroup represents a group of - [TransitionRoutes][google.cloud.dialogflow.cx.v3.TransitionRoute] - to be used by a - [Page][google.cloud.dialogflow.cx.v3.Page]. - - """ - # 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, transition_route_group]) - 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 = gcdc_transition_route_group.CreateTransitionRouteGroupRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if transition_route_group is not None: - request.transition_route_group = transition_route_group - - # 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_transition_route_group, - 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_transition_route_group(self, - request: Optional[Union[gcdc_transition_route_group.UpdateTransitionRouteGroupRequest, dict]] = None, - *, - transition_route_group: Optional[gcdc_transition_route_group.TransitionRouteGroup] = 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]] = (), - ) -> gcdc_transition_route_group.TransitionRouteGroup: - r"""Updates the specified - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - async def sample_update_transition_route_group(): - # Create a client - client = dialogflowcx_v3.TransitionRouteGroupsAsyncClient() - - # Initialize request argument(s) - transition_route_group = dialogflowcx_v3.TransitionRouteGroup() - transition_route_group.display_name = "display_name_value" - - request = dialogflowcx_v3.UpdateTransitionRouteGroupRequest( - transition_route_group=transition_route_group, - ) - - # Make the request - response = await client.update_transition_route_group(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.UpdateTransitionRouteGroupRequest, dict]]): - The request object. The request message for - [TransitionRouteGroups.UpdateTransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroups.UpdateTransitionRouteGroup]. - transition_route_group (:class:`google.cloud.dialogflowcx_v3.types.TransitionRouteGroup`): - Required. The transition route group - to update. - - This corresponds to the ``transition_route_group`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The mask to control which fields get - 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.dialogflowcx_v3.types.TransitionRouteGroup: - A TransitionRouteGroup represents a group of - [TransitionRoutes][google.cloud.dialogflow.cx.v3.TransitionRoute] - to be used by a - [Page][google.cloud.dialogflow.cx.v3.Page]. - - """ - # 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([transition_route_group, 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 = gcdc_transition_route_group.UpdateTransitionRouteGroupRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if transition_route_group is not None: - request.transition_route_group = transition_route_group - 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_transition_route_group, - 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(( - ("transition_route_group.name", request.transition_route_group.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_transition_route_group(self, - request: Optional[Union[transition_route_group.DeleteTransitionRouteGroupRequest, 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 the specified - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - async def sample_delete_transition_route_group(): - # Create a client - client = dialogflowcx_v3.TransitionRouteGroupsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteTransitionRouteGroupRequest( - name="name_value", - ) - - # Make the request - await client.delete_transition_route_group(request=request) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.DeleteTransitionRouteGroupRequest, dict]]): - The request object. The request message for - [TransitionRouteGroups.DeleteTransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroups.DeleteTransitionRouteGroup]. - name (:class:`str`): - Required. The name of the - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - to delete. Format: - ``projects//locations//agents//flows//transitionRouteGroups/`` - or - ``projects//locations//agents//transitionRouteGroups/``. - - 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 = transition_route_group.DeleteTransitionRouteGroupRequest(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_transition_route_group, - 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 get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**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_location, - 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_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**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_locations, - 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 __aenter__(self) -> "TransitionRouteGroupsAsyncClient": - 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__ = ( - "TransitionRouteGroupsAsyncClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/client.py deleted file mode 100644 index 86da0b04..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/client.py +++ /dev/null @@ -1,1274 +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.dialogflowcx_v3 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.cloud.dialogflowcx_v3.services.transition_route_groups import pagers -from google.cloud.dialogflowcx_v3.types import page -from google.cloud.dialogflowcx_v3.types import transition_route_group -from google.cloud.dialogflowcx_v3.types import transition_route_group as gcdc_transition_route_group -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import TransitionRouteGroupsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import TransitionRouteGroupsGrpcTransport -from .transports.grpc_asyncio import TransitionRouteGroupsGrpcAsyncIOTransport -from .transports.rest import TransitionRouteGroupsRestTransport - - -class TransitionRouteGroupsClientMeta(type): - """Metaclass for the TransitionRouteGroups 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[TransitionRouteGroupsTransport]] - _transport_registry["grpc"] = TransitionRouteGroupsGrpcTransport - _transport_registry["grpc_asyncio"] = TransitionRouteGroupsGrpcAsyncIOTransport - _transport_registry["rest"] = TransitionRouteGroupsRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[TransitionRouteGroupsTransport]: - """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 TransitionRouteGroupsClient(metaclass=TransitionRouteGroupsClientMeta): - """Service for managing - [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - """ - - @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 = "dialogflow.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: - TransitionRouteGroupsClient: 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: - TransitionRouteGroupsClient: 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) -> TransitionRouteGroupsTransport: - """Returns the transport used by the client instance. - - Returns: - TransitionRouteGroupsTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def flow_path(project: str,location: str,agent: str,flow: str,) -> str: - """Returns a fully-qualified flow string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}".format(project=project, location=location, agent=agent, flow=flow, ) - - @staticmethod - def parse_flow_path(path: str) -> Dict[str,str]: - """Parses a flow path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def intent_path(project: str,location: str,agent: str,intent: str,) -> str: - """Returns a fully-qualified intent string.""" - return "projects/{project}/locations/{location}/agents/{agent}/intents/{intent}".format(project=project, location=location, agent=agent, intent=intent, ) - - @staticmethod - def parse_intent_path(path: str) -> Dict[str,str]: - """Parses a intent path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/intents/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def page_path(project: str,location: str,agent: str,flow: str,page: str,) -> str: - """Returns a fully-qualified page string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page}".format(project=project, location=location, agent=agent, flow=flow, page=page, ) - - @staticmethod - def parse_page_path(path: str) -> Dict[str,str]: - """Parses a page path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)/pages/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def transition_route_group_path(project: str,location: str,agent: str,flow: str,transition_route_group: str,) -> str: - """Returns a fully-qualified transition_route_group string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}".format(project=project, location=location, agent=agent, flow=flow, transition_route_group=transition_route_group, ) - - @staticmethod - def parse_transition_route_group_path(path: str) -> Dict[str,str]: - """Parses a transition_route_group path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)/transitionRouteGroups/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def webhook_path(project: str,location: str,agent: str,webhook: str,) -> str: - """Returns a fully-qualified webhook string.""" - return "projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}".format(project=project, location=location, agent=agent, webhook=webhook, ) - - @staticmethod - def parse_webhook_path(path: str) -> Dict[str,str]: - """Parses a webhook path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/webhooks/(?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, TransitionRouteGroupsTransport]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the transition route groups 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, TransitionRouteGroupsTransport]): 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, TransitionRouteGroupsTransport): - # transport is a TransitionRouteGroupsTransport 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 list_transition_route_groups(self, - request: Optional[Union[transition_route_group.ListTransitionRouteGroupsRequest, 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.ListTransitionRouteGroupsPager: - r"""Returns the list of all transition route groups in - the specified flow. - - .. 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 dialogflowcx_v3 - - def sample_list_transition_route_groups(): - # Create a client - client = dialogflowcx_v3.TransitionRouteGroupsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListTransitionRouteGroupsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_transition_route_groups(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ListTransitionRouteGroupsRequest, dict]): - The request object. The request message for - [TransitionRouteGroups.ListTransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroups.ListTransitionRouteGroups]. - parent (str): - Required. The flow to list all transition route groups - for. Format: - ``projects//locations//agents//flows/`` - or \`projects//locations//agents/. - - 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.dialogflowcx_v3.services.transition_route_groups.pagers.ListTransitionRouteGroupsPager: - The response message for - [TransitionRouteGroups.ListTransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroups.ListTransitionRouteGroups]. - - 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 transition_route_group.ListTransitionRouteGroupsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, transition_route_group.ListTransitionRouteGroupsRequest): - request = transition_route_group.ListTransitionRouteGroupsRequest(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_transition_route_groups] - - # 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.ListTransitionRouteGroupsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_transition_route_group(self, - request: Optional[Union[transition_route_group.GetTransitionRouteGroupRequest, 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]] = (), - ) -> transition_route_group.TransitionRouteGroup: - r"""Retrieves the specified - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - - .. 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 dialogflowcx_v3 - - def sample_get_transition_route_group(): - # Create a client - client = dialogflowcx_v3.TransitionRouteGroupsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetTransitionRouteGroupRequest( - name="name_value", - ) - - # Make the request - response = client.get_transition_route_group(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.GetTransitionRouteGroupRequest, dict]): - The request object. The request message for - [TransitionRouteGroups.GetTransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroups.GetTransitionRouteGroup]. - name (str): - Required. The name of the - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - Format: - ``projects//locations//agents//flows//transitionRouteGroups/`` - or - ``projects//locations//agents//transitionRouteGroups/``. - - 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.dialogflowcx_v3.types.TransitionRouteGroup: - A TransitionRouteGroup represents a group of - [TransitionRoutes][google.cloud.dialogflow.cx.v3.TransitionRoute] - to be used by a - [Page][google.cloud.dialogflow.cx.v3.Page]. - - """ - # 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 transition_route_group.GetTransitionRouteGroupRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, transition_route_group.GetTransitionRouteGroupRequest): - request = transition_route_group.GetTransitionRouteGroupRequest(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_transition_route_group] - - # 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 create_transition_route_group(self, - request: Optional[Union[gcdc_transition_route_group.CreateTransitionRouteGroupRequest, dict]] = None, - *, - parent: Optional[str] = None, - transition_route_group: Optional[gcdc_transition_route_group.TransitionRouteGroup] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_transition_route_group.TransitionRouteGroup: - r"""Creates an - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - in the specified flow. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - def sample_create_transition_route_group(): - # Create a client - client = dialogflowcx_v3.TransitionRouteGroupsClient() - - # Initialize request argument(s) - transition_route_group = dialogflowcx_v3.TransitionRouteGroup() - transition_route_group.display_name = "display_name_value" - - request = dialogflowcx_v3.CreateTransitionRouteGroupRequest( - parent="parent_value", - transition_route_group=transition_route_group, - ) - - # Make the request - response = client.create_transition_route_group(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.CreateTransitionRouteGroupRequest, dict]): - The request object. The request message for - [TransitionRouteGroups.CreateTransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroups.CreateTransitionRouteGroup]. - parent (str): - Required. The flow to create an - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - for. Format: - ``projects//locations//agents//flows/`` - or - ``projects//locations//agents/`` - for agent-level groups. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - transition_route_group (google.cloud.dialogflowcx_v3.types.TransitionRouteGroup): - Required. The transition route group - to create. - - This corresponds to the ``transition_route_group`` 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.dialogflowcx_v3.types.TransitionRouteGroup: - A TransitionRouteGroup represents a group of - [TransitionRoutes][google.cloud.dialogflow.cx.v3.TransitionRoute] - to be used by a - [Page][google.cloud.dialogflow.cx.v3.Page]. - - """ - # 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, transition_route_group]) - 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 gcdc_transition_route_group.CreateTransitionRouteGroupRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_transition_route_group.CreateTransitionRouteGroupRequest): - request = gcdc_transition_route_group.CreateTransitionRouteGroupRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if transition_route_group is not None: - request.transition_route_group = transition_route_group - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_transition_route_group] - - # 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_transition_route_group(self, - request: Optional[Union[gcdc_transition_route_group.UpdateTransitionRouteGroupRequest, dict]] = None, - *, - transition_route_group: Optional[gcdc_transition_route_group.TransitionRouteGroup] = 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]] = (), - ) -> gcdc_transition_route_group.TransitionRouteGroup: - r"""Updates the specified - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - def sample_update_transition_route_group(): - # Create a client - client = dialogflowcx_v3.TransitionRouteGroupsClient() - - # Initialize request argument(s) - transition_route_group = dialogflowcx_v3.TransitionRouteGroup() - transition_route_group.display_name = "display_name_value" - - request = dialogflowcx_v3.UpdateTransitionRouteGroupRequest( - transition_route_group=transition_route_group, - ) - - # Make the request - response = client.update_transition_route_group(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.UpdateTransitionRouteGroupRequest, dict]): - The request object. The request message for - [TransitionRouteGroups.UpdateTransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroups.UpdateTransitionRouteGroup]. - transition_route_group (google.cloud.dialogflowcx_v3.types.TransitionRouteGroup): - Required. The transition route group - to update. - - This corresponds to the ``transition_route_group`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The mask to control which fields get - 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.dialogflowcx_v3.types.TransitionRouteGroup: - A TransitionRouteGroup represents a group of - [TransitionRoutes][google.cloud.dialogflow.cx.v3.TransitionRoute] - to be used by a - [Page][google.cloud.dialogflow.cx.v3.Page]. - - """ - # 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([transition_route_group, 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 gcdc_transition_route_group.UpdateTransitionRouteGroupRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_transition_route_group.UpdateTransitionRouteGroupRequest): - request = gcdc_transition_route_group.UpdateTransitionRouteGroupRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if transition_route_group is not None: - request.transition_route_group = transition_route_group - 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_transition_route_group] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("transition_route_group.name", request.transition_route_group.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_transition_route_group(self, - request: Optional[Union[transition_route_group.DeleteTransitionRouteGroupRequest, 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 the specified - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - .. 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 dialogflowcx_v3 - - def sample_delete_transition_route_group(): - # Create a client - client = dialogflowcx_v3.TransitionRouteGroupsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteTransitionRouteGroupRequest( - name="name_value", - ) - - # Make the request - client.delete_transition_route_group(request=request) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.DeleteTransitionRouteGroupRequest, dict]): - The request object. The request message for - [TransitionRouteGroups.DeleteTransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroups.DeleteTransitionRouteGroup]. - name (str): - Required. The name of the - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - to delete. Format: - ``projects//locations//agents//flows//transitionRouteGroups/`` - or - ``projects//locations//agents//transitionRouteGroups/``. - - 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 transition_route_group.DeleteTransitionRouteGroupRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, transition_route_group.DeleteTransitionRouteGroupRequest): - request = transition_route_group.DeleteTransitionRouteGroupRequest(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_transition_route_group] - - # 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) -> "TransitionRouteGroupsClient": - 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,) - - def get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.get_location, - 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 list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.list_locations, - 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 - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "TransitionRouteGroupsClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/pagers.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/pagers.py deleted file mode 100644 index 0782363e..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/pagers.py +++ /dev/null @@ -1,139 +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.dialogflowcx_v3.types import transition_route_group - - -class ListTransitionRouteGroupsPager: - """A pager for iterating through ``list_transition_route_groups`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListTransitionRouteGroupsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``transition_route_groups`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListTransitionRouteGroups`` requests and continue to iterate - through the ``transition_route_groups`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListTransitionRouteGroupsResponse` - 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[..., transition_route_group.ListTransitionRouteGroupsResponse], - request: transition_route_group.ListTransitionRouteGroupsRequest, - response: transition_route_group.ListTransitionRouteGroupsResponse, - *, - 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.dialogflowcx_v3.types.ListTransitionRouteGroupsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListTransitionRouteGroupsResponse): - 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 = transition_route_group.ListTransitionRouteGroupsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[transition_route_group.ListTransitionRouteGroupsResponse]: - 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[transition_route_group.TransitionRouteGroup]: - for page in self.pages: - yield from page.transition_route_groups - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListTransitionRouteGroupsAsyncPager: - """A pager for iterating through ``list_transition_route_groups`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListTransitionRouteGroupsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``transition_route_groups`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListTransitionRouteGroups`` requests and continue to iterate - through the ``transition_route_groups`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListTransitionRouteGroupsResponse` - 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[transition_route_group.ListTransitionRouteGroupsResponse]], - request: transition_route_group.ListTransitionRouteGroupsRequest, - response: transition_route_group.ListTransitionRouteGroupsResponse, - *, - 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.dialogflowcx_v3.types.ListTransitionRouteGroupsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListTransitionRouteGroupsResponse): - 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 = transition_route_group.ListTransitionRouteGroupsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[transition_route_group.ListTransitionRouteGroupsResponse]: - 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[transition_route_group.TransitionRouteGroup]: - async def async_generator(): - async for page in self.pages: - for response in page.transition_route_groups: - 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/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/__init__.py deleted file mode 100644 index f965cbb3..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/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 TransitionRouteGroupsTransport -from .grpc import TransitionRouteGroupsGrpcTransport -from .grpc_asyncio import TransitionRouteGroupsGrpcAsyncIOTransport -from .rest import TransitionRouteGroupsRestTransport -from .rest import TransitionRouteGroupsRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[TransitionRouteGroupsTransport]] -_transport_registry['grpc'] = TransitionRouteGroupsGrpcTransport -_transport_registry['grpc_asyncio'] = TransitionRouteGroupsGrpcAsyncIOTransport -_transport_registry['rest'] = TransitionRouteGroupsRestTransport - -__all__ = ( - 'TransitionRouteGroupsTransport', - 'TransitionRouteGroupsGrpcTransport', - 'TransitionRouteGroupsGrpcAsyncIOTransport', - 'TransitionRouteGroupsRestTransport', - 'TransitionRouteGroupsRestInterceptor', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/base.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/base.py deleted file mode 100644 index feb2950b..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/base.py +++ /dev/null @@ -1,252 +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.dialogflowcx_v3 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.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.dialogflowcx_v3.types import transition_route_group -from google.cloud.dialogflowcx_v3.types import transition_route_group as gcdc_transition_route_group -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -class TransitionRouteGroupsTransport(abc.ABC): - """Abstract transport class for TransitionRouteGroups.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/dialogflow', - ) - - DEFAULT_HOST: str = 'dialogflow.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.list_transition_route_groups: gapic_v1.method.wrap_method( - self.list_transition_route_groups, - default_timeout=None, - client_info=client_info, - ), - self.get_transition_route_group: gapic_v1.method.wrap_method( - self.get_transition_route_group, - default_timeout=None, - client_info=client_info, - ), - self.create_transition_route_group: gapic_v1.method.wrap_method( - self.create_transition_route_group, - default_timeout=None, - client_info=client_info, - ), - self.update_transition_route_group: gapic_v1.method.wrap_method( - self.update_transition_route_group, - default_timeout=None, - client_info=client_info, - ), - self.delete_transition_route_group: gapic_v1.method.wrap_method( - self.delete_transition_route_group, - 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 list_transition_route_groups(self) -> Callable[ - [transition_route_group.ListTransitionRouteGroupsRequest], - Union[ - transition_route_group.ListTransitionRouteGroupsResponse, - Awaitable[transition_route_group.ListTransitionRouteGroupsResponse] - ]]: - raise NotImplementedError() - - @property - def get_transition_route_group(self) -> Callable[ - [transition_route_group.GetTransitionRouteGroupRequest], - Union[ - transition_route_group.TransitionRouteGroup, - Awaitable[transition_route_group.TransitionRouteGroup] - ]]: - raise NotImplementedError() - - @property - def create_transition_route_group(self) -> Callable[ - [gcdc_transition_route_group.CreateTransitionRouteGroupRequest], - Union[ - gcdc_transition_route_group.TransitionRouteGroup, - Awaitable[gcdc_transition_route_group.TransitionRouteGroup] - ]]: - raise NotImplementedError() - - @property - def update_transition_route_group(self) -> Callable[ - [gcdc_transition_route_group.UpdateTransitionRouteGroupRequest], - Union[ - gcdc_transition_route_group.TransitionRouteGroup, - Awaitable[gcdc_transition_route_group.TransitionRouteGroup] - ]]: - raise NotImplementedError() - - @property - def delete_transition_route_group(self) -> Callable[ - [transition_route_group.DeleteTransitionRouteGroupRequest], - 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 get_location(self, - ) -> Callable[ - [locations_pb2.GetLocationRequest], - Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], - ]: - raise NotImplementedError() - - @property - def list_locations(self, - ) -> Callable[ - [locations_pb2.ListLocationsRequest], - Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'TransitionRouteGroupsTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/grpc.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/grpc.py deleted file mode 100644 index 274d23ed..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/grpc.py +++ /dev/null @@ -1,481 +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 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.dialogflowcx_v3.types import transition_route_group -from google.cloud.dialogflowcx_v3.types import transition_route_group as gcdc_transition_route_group -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from .base import TransitionRouteGroupsTransport, DEFAULT_CLIENT_INFO - - -class TransitionRouteGroupsGrpcTransport(TransitionRouteGroupsTransport): - """gRPC backend transport for TransitionRouteGroups. - - Service for managing - [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - - 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 = 'dialogflow.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] = {} - - 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 = 'dialogflow.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 list_transition_route_groups(self) -> Callable[ - [transition_route_group.ListTransitionRouteGroupsRequest], - transition_route_group.ListTransitionRouteGroupsResponse]: - r"""Return a callable for the list transition route groups method over gRPC. - - Returns the list of all transition route groups in - the specified flow. - - Returns: - Callable[[~.ListTransitionRouteGroupsRequest], - ~.ListTransitionRouteGroupsResponse]: - 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_transition_route_groups' not in self._stubs: - self._stubs['list_transition_route_groups'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TransitionRouteGroups/ListTransitionRouteGroups', - request_serializer=transition_route_group.ListTransitionRouteGroupsRequest.serialize, - response_deserializer=transition_route_group.ListTransitionRouteGroupsResponse.deserialize, - ) - return self._stubs['list_transition_route_groups'] - - @property - def get_transition_route_group(self) -> Callable[ - [transition_route_group.GetTransitionRouteGroupRequest], - transition_route_group.TransitionRouteGroup]: - r"""Return a callable for the get transition route group method over gRPC. - - Retrieves the specified - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - - Returns: - Callable[[~.GetTransitionRouteGroupRequest], - ~.TransitionRouteGroup]: - 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_transition_route_group' not in self._stubs: - self._stubs['get_transition_route_group'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TransitionRouteGroups/GetTransitionRouteGroup', - request_serializer=transition_route_group.GetTransitionRouteGroupRequest.serialize, - response_deserializer=transition_route_group.TransitionRouteGroup.deserialize, - ) - return self._stubs['get_transition_route_group'] - - @property - def create_transition_route_group(self) -> Callable[ - [gcdc_transition_route_group.CreateTransitionRouteGroupRequest], - gcdc_transition_route_group.TransitionRouteGroup]: - r"""Return a callable for the create transition route group method over gRPC. - - Creates an - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - in the specified flow. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.CreateTransitionRouteGroupRequest], - ~.TransitionRouteGroup]: - 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_transition_route_group' not in self._stubs: - self._stubs['create_transition_route_group'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TransitionRouteGroups/CreateTransitionRouteGroup', - request_serializer=gcdc_transition_route_group.CreateTransitionRouteGroupRequest.serialize, - response_deserializer=gcdc_transition_route_group.TransitionRouteGroup.deserialize, - ) - return self._stubs['create_transition_route_group'] - - @property - def update_transition_route_group(self) -> Callable[ - [gcdc_transition_route_group.UpdateTransitionRouteGroupRequest], - gcdc_transition_route_group.TransitionRouteGroup]: - r"""Return a callable for the update transition route group method over gRPC. - - Updates the specified - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.UpdateTransitionRouteGroupRequest], - ~.TransitionRouteGroup]: - 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_transition_route_group' not in self._stubs: - self._stubs['update_transition_route_group'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TransitionRouteGroups/UpdateTransitionRouteGroup', - request_serializer=gcdc_transition_route_group.UpdateTransitionRouteGroupRequest.serialize, - response_deserializer=gcdc_transition_route_group.TransitionRouteGroup.deserialize, - ) - return self._stubs['update_transition_route_group'] - - @property - def delete_transition_route_group(self) -> Callable[ - [transition_route_group.DeleteTransitionRouteGroupRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete transition route group method over gRPC. - - Deletes the specified - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.DeleteTransitionRouteGroupRequest], - ~.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_transition_route_group' not in self._stubs: - self._stubs['delete_transition_route_group'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TransitionRouteGroups/DeleteTransitionRouteGroup', - request_serializer=transition_route_group.DeleteTransitionRouteGroupRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_transition_route_group'] - - 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 list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'TransitionRouteGroupsGrpcTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/grpc_asyncio.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/grpc_asyncio.py deleted file mode 100644 index 29043fa0..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/grpc_asyncio.py +++ /dev/null @@ -1,480 +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.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.dialogflowcx_v3.types import transition_route_group -from google.cloud.dialogflowcx_v3.types import transition_route_group as gcdc_transition_route_group -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from .base import TransitionRouteGroupsTransport, DEFAULT_CLIENT_INFO -from .grpc import TransitionRouteGroupsGrpcTransport - - -class TransitionRouteGroupsGrpcAsyncIOTransport(TransitionRouteGroupsTransport): - """gRPC AsyncIO backend transport for TransitionRouteGroups. - - Service for managing - [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - - 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 = 'dialogflow.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 = 'dialogflow.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] = {} - - 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 list_transition_route_groups(self) -> Callable[ - [transition_route_group.ListTransitionRouteGroupsRequest], - Awaitable[transition_route_group.ListTransitionRouteGroupsResponse]]: - r"""Return a callable for the list transition route groups method over gRPC. - - Returns the list of all transition route groups in - the specified flow. - - Returns: - Callable[[~.ListTransitionRouteGroupsRequest], - Awaitable[~.ListTransitionRouteGroupsResponse]]: - 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_transition_route_groups' not in self._stubs: - self._stubs['list_transition_route_groups'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TransitionRouteGroups/ListTransitionRouteGroups', - request_serializer=transition_route_group.ListTransitionRouteGroupsRequest.serialize, - response_deserializer=transition_route_group.ListTransitionRouteGroupsResponse.deserialize, - ) - return self._stubs['list_transition_route_groups'] - - @property - def get_transition_route_group(self) -> Callable[ - [transition_route_group.GetTransitionRouteGroupRequest], - Awaitable[transition_route_group.TransitionRouteGroup]]: - r"""Return a callable for the get transition route group method over gRPC. - - Retrieves the specified - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - - Returns: - Callable[[~.GetTransitionRouteGroupRequest], - Awaitable[~.TransitionRouteGroup]]: - 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_transition_route_group' not in self._stubs: - self._stubs['get_transition_route_group'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TransitionRouteGroups/GetTransitionRouteGroup', - request_serializer=transition_route_group.GetTransitionRouteGroupRequest.serialize, - response_deserializer=transition_route_group.TransitionRouteGroup.deserialize, - ) - return self._stubs['get_transition_route_group'] - - @property - def create_transition_route_group(self) -> Callable[ - [gcdc_transition_route_group.CreateTransitionRouteGroupRequest], - Awaitable[gcdc_transition_route_group.TransitionRouteGroup]]: - r"""Return a callable for the create transition route group method over gRPC. - - Creates an - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - in the specified flow. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.CreateTransitionRouteGroupRequest], - Awaitable[~.TransitionRouteGroup]]: - 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_transition_route_group' not in self._stubs: - self._stubs['create_transition_route_group'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TransitionRouteGroups/CreateTransitionRouteGroup', - request_serializer=gcdc_transition_route_group.CreateTransitionRouteGroupRequest.serialize, - response_deserializer=gcdc_transition_route_group.TransitionRouteGroup.deserialize, - ) - return self._stubs['create_transition_route_group'] - - @property - def update_transition_route_group(self) -> Callable[ - [gcdc_transition_route_group.UpdateTransitionRouteGroupRequest], - Awaitable[gcdc_transition_route_group.TransitionRouteGroup]]: - r"""Return a callable for the update transition route group method over gRPC. - - Updates the specified - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.UpdateTransitionRouteGroupRequest], - Awaitable[~.TransitionRouteGroup]]: - 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_transition_route_group' not in self._stubs: - self._stubs['update_transition_route_group'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TransitionRouteGroups/UpdateTransitionRouteGroup', - request_serializer=gcdc_transition_route_group.UpdateTransitionRouteGroupRequest.serialize, - response_deserializer=gcdc_transition_route_group.TransitionRouteGroup.deserialize, - ) - return self._stubs['update_transition_route_group'] - - @property - def delete_transition_route_group(self) -> Callable[ - [transition_route_group.DeleteTransitionRouteGroupRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete transition route group method over gRPC. - - Deletes the specified - [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - - Note: You should always train a flow prior to sending it - queries. See the `training - documentation `__. - - Returns: - Callable[[~.DeleteTransitionRouteGroupRequest], - 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_transition_route_group' not in self._stubs: - self._stubs['delete_transition_route_group'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.TransitionRouteGroups/DeleteTransitionRouteGroup', - request_serializer=transition_route_group.DeleteTransitionRouteGroupRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_transition_route_group'] - - 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"] - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - -__all__ = ( - 'TransitionRouteGroupsGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/rest.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/rest.py deleted file mode 100644 index 75a79668..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/rest.py +++ /dev/null @@ -1,1205 +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.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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.dialogflowcx_v3.types import transition_route_group -from google.cloud.dialogflowcx_v3.types import transition_route_group as gcdc_transition_route_group -from google.protobuf import empty_pb2 # type: ignore - -from .base import TransitionRouteGroupsTransport, 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 TransitionRouteGroupsRestInterceptor: - """Interceptor for TransitionRouteGroups. - - 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 TransitionRouteGroupsRestTransport. - - .. code-block:: python - class MyCustomTransitionRouteGroupsInterceptor(TransitionRouteGroupsRestInterceptor): - def pre_create_transition_route_group(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_transition_route_group(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_transition_route_group(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_get_transition_route_group(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_transition_route_group(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_transition_route_groups(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_transition_route_groups(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_transition_route_group(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_transition_route_group(self, response): - logging.log(f"Received response: {response}") - return response - - transport = TransitionRouteGroupsRestTransport(interceptor=MyCustomTransitionRouteGroupsInterceptor()) - client = TransitionRouteGroupsClient(transport=transport) - - - """ - def pre_create_transition_route_group(self, request: gcdc_transition_route_group.CreateTransitionRouteGroupRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_transition_route_group.CreateTransitionRouteGroupRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_transition_route_group - - Override in a subclass to manipulate the request or metadata - before they are sent to the TransitionRouteGroups server. - """ - return request, metadata - - def post_create_transition_route_group(self, response: gcdc_transition_route_group.TransitionRouteGroup) -> gcdc_transition_route_group.TransitionRouteGroup: - """Post-rpc interceptor for create_transition_route_group - - Override in a subclass to manipulate the response - after it is returned by the TransitionRouteGroups server but before - it is returned to user code. - """ - return response - def pre_delete_transition_route_group(self, request: transition_route_group.DeleteTransitionRouteGroupRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[transition_route_group.DeleteTransitionRouteGroupRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_transition_route_group - - Override in a subclass to manipulate the request or metadata - before they are sent to the TransitionRouteGroups server. - """ - return request, metadata - - def pre_get_transition_route_group(self, request: transition_route_group.GetTransitionRouteGroupRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[transition_route_group.GetTransitionRouteGroupRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_transition_route_group - - Override in a subclass to manipulate the request or metadata - before they are sent to the TransitionRouteGroups server. - """ - return request, metadata - - def post_get_transition_route_group(self, response: transition_route_group.TransitionRouteGroup) -> transition_route_group.TransitionRouteGroup: - """Post-rpc interceptor for get_transition_route_group - - Override in a subclass to manipulate the response - after it is returned by the TransitionRouteGroups server but before - it is returned to user code. - """ - return response - def pre_list_transition_route_groups(self, request: transition_route_group.ListTransitionRouteGroupsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[transition_route_group.ListTransitionRouteGroupsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_transition_route_groups - - Override in a subclass to manipulate the request or metadata - before they are sent to the TransitionRouteGroups server. - """ - return request, metadata - - def post_list_transition_route_groups(self, response: transition_route_group.ListTransitionRouteGroupsResponse) -> transition_route_group.ListTransitionRouteGroupsResponse: - """Post-rpc interceptor for list_transition_route_groups - - Override in a subclass to manipulate the response - after it is returned by the TransitionRouteGroups server but before - it is returned to user code. - """ - return response - def pre_update_transition_route_group(self, request: gcdc_transition_route_group.UpdateTransitionRouteGroupRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_transition_route_group.UpdateTransitionRouteGroupRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_transition_route_group - - Override in a subclass to manipulate the request or metadata - before they are sent to the TransitionRouteGroups server. - """ - return request, metadata - - def post_update_transition_route_group(self, response: gcdc_transition_route_group.TransitionRouteGroup) -> gcdc_transition_route_group.TransitionRouteGroup: - """Post-rpc interceptor for update_transition_route_group - - Override in a subclass to manipulate the response - after it is returned by the TransitionRouteGroups server but before - it is returned to user code. - """ - return response - - def pre_get_location( - self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_location - - Override in a subclass to manipulate the request or metadata - before they are sent to the TransitionRouteGroups server. - """ - return request, metadata - - def post_get_location( - self, response: locations_pb2.Location - ) -> locations_pb2.Location: - """Post-rpc interceptor for get_location - - Override in a subclass to manipulate the response - after it is returned by the TransitionRouteGroups server but before - it is returned to user code. - """ - return response - def pre_list_locations( - self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_locations - - Override in a subclass to manipulate the request or metadata - before they are sent to the TransitionRouteGroups server. - """ - return request, metadata - - def post_list_locations( - self, response: locations_pb2.ListLocationsResponse - ) -> locations_pb2.ListLocationsResponse: - """Post-rpc interceptor for list_locations - - Override in a subclass to manipulate the response - after it is returned by the TransitionRouteGroups 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 TransitionRouteGroups 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 TransitionRouteGroups 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 TransitionRouteGroups 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 TransitionRouteGroups 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 TransitionRouteGroups 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 TransitionRouteGroups server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class TransitionRouteGroupsRestStub: - _session: AuthorizedSession - _host: str - _interceptor: TransitionRouteGroupsRestInterceptor - - -class TransitionRouteGroupsRestTransport(TransitionRouteGroupsTransport): - """REST backend transport for TransitionRouteGroups. - - Service for managing - [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. - - 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 = 'dialogflow.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[TransitionRouteGroupsRestInterceptor] = 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) - if client_cert_source_for_mtls: - self._session.configure_mtls_channel(client_cert_source_for_mtls) - self._interceptor = interceptor or TransitionRouteGroupsRestInterceptor() - self._prep_wrapped_messages(client_info) - - class _CreateTransitionRouteGroup(TransitionRouteGroupsRestStub): - def __hash__(self): - return hash("CreateTransitionRouteGroup") - - __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: gcdc_transition_route_group.CreateTransitionRouteGroupRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_transition_route_group.TransitionRouteGroup: - r"""Call the create transition route - group method over HTTP. - - Args: - request (~.gcdc_transition_route_group.CreateTransitionRouteGroupRequest): - The request object. The request message for - [TransitionRouteGroups.CreateTransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroups.CreateTransitionRouteGroup]. - 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: - ~.gcdc_transition_route_group.TransitionRouteGroup: - A TransitionRouteGroup represents a group of - [``TransitionRoutes``][google.cloud.dialogflow.cx.v3.TransitionRoute] - to be used by a - [Page][google.cloud.dialogflow.cx.v3.Page]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*/flows/*}/transitionRouteGroups', - 'body': 'transition_route_group', - }, -{ - 'method': 'post', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*}/transitionRouteGroups', - 'body': 'transition_route_group', - }, - ] - request, metadata = self._interceptor.pre_create_transition_route_group(request, metadata) - pb_request = gcdc_transition_route_group.CreateTransitionRouteGroupRequest.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 = gcdc_transition_route_group.TransitionRouteGroup() - pb_resp = gcdc_transition_route_group.TransitionRouteGroup.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_transition_route_group(resp) - return resp - - class _DeleteTransitionRouteGroup(TransitionRouteGroupsRestStub): - def __hash__(self): - return hash("DeleteTransitionRouteGroup") - - __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: transition_route_group.DeleteTransitionRouteGroupRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete transition route - group method over HTTP. - - Args: - request (~.transition_route_group.DeleteTransitionRouteGroupRequest): - The request object. The request message for - [TransitionRouteGroups.DeleteTransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroups.DeleteTransitionRouteGroup]. - 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': '/v3/{name=projects/*/locations/*/agents/*/flows/*/transitionRouteGroups/*}', - }, -{ - 'method': 'delete', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/transitionRouteGroups/*}', - }, - ] - request, metadata = self._interceptor.pre_delete_transition_route_group(request, metadata) - pb_request = transition_route_group.DeleteTransitionRouteGroupRequest.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 _GetTransitionRouteGroup(TransitionRouteGroupsRestStub): - def __hash__(self): - return hash("GetTransitionRouteGroup") - - __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: transition_route_group.GetTransitionRouteGroupRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> transition_route_group.TransitionRouteGroup: - r"""Call the get transition route - group method over HTTP. - - Args: - request (~.transition_route_group.GetTransitionRouteGroupRequest): - The request object. The request message for - [TransitionRouteGroups.GetTransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroups.GetTransitionRouteGroup]. - 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: - ~.transition_route_group.TransitionRouteGroup: - A TransitionRouteGroup represents a group of - [``TransitionRoutes``][google.cloud.dialogflow.cx.v3.TransitionRoute] - to be used by a - [Page][google.cloud.dialogflow.cx.v3.Page]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/flows/*/transitionRouteGroups/*}', - }, -{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/transitionRouteGroups/*}', - }, - ] - request, metadata = self._interceptor.pre_get_transition_route_group(request, metadata) - pb_request = transition_route_group.GetTransitionRouteGroupRequest.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 = transition_route_group.TransitionRouteGroup() - pb_resp = transition_route_group.TransitionRouteGroup.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_transition_route_group(resp) - return resp - - class _ListTransitionRouteGroups(TransitionRouteGroupsRestStub): - def __hash__(self): - return hash("ListTransitionRouteGroups") - - __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: transition_route_group.ListTransitionRouteGroupsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> transition_route_group.ListTransitionRouteGroupsResponse: - r"""Call the list transition route - groups method over HTTP. - - Args: - request (~.transition_route_group.ListTransitionRouteGroupsRequest): - The request object. The request message for - [TransitionRouteGroups.ListTransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroups.ListTransitionRouteGroups]. - 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: - ~.transition_route_group.ListTransitionRouteGroupsResponse: - The response message for - [TransitionRouteGroups.ListTransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroups.ListTransitionRouteGroups]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*/flows/*}/transitionRouteGroups', - }, -{ - 'method': 'get', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*}/transitionRouteGroups', - }, - ] - request, metadata = self._interceptor.pre_list_transition_route_groups(request, metadata) - pb_request = transition_route_group.ListTransitionRouteGroupsRequest.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 = transition_route_group.ListTransitionRouteGroupsResponse() - pb_resp = transition_route_group.ListTransitionRouteGroupsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_transition_route_groups(resp) - return resp - - class _UpdateTransitionRouteGroup(TransitionRouteGroupsRestStub): - def __hash__(self): - return hash("UpdateTransitionRouteGroup") - - __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: gcdc_transition_route_group.UpdateTransitionRouteGroupRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_transition_route_group.TransitionRouteGroup: - r"""Call the update transition route - group method over HTTP. - - Args: - request (~.gcdc_transition_route_group.UpdateTransitionRouteGroupRequest): - The request object. The request message for - [TransitionRouteGroups.UpdateTransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroups.UpdateTransitionRouteGroup]. - 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: - ~.gcdc_transition_route_group.TransitionRouteGroup: - A TransitionRouteGroup represents a group of - [``TransitionRoutes``][google.cloud.dialogflow.cx.v3.TransitionRoute] - to be used by a - [Page][google.cloud.dialogflow.cx.v3.Page]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v3/{transition_route_group.name=projects/*/locations/*/agents/*/flows/*/transitionRouteGroups/*}', - 'body': 'transition_route_group', - }, -{ - 'method': 'patch', - 'uri': '/v3/{transition_route_group.name=projects/*/locations/*/agents/*/transitionRouteGroups/*}', - 'body': 'transition_route_group', - }, - ] - request, metadata = self._interceptor.pre_update_transition_route_group(request, metadata) - pb_request = gcdc_transition_route_group.UpdateTransitionRouteGroupRequest.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 = gcdc_transition_route_group.TransitionRouteGroup() - pb_resp = gcdc_transition_route_group.TransitionRouteGroup.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_transition_route_group(resp) - return resp - - @property - def create_transition_route_group(self) -> Callable[ - [gcdc_transition_route_group.CreateTransitionRouteGroupRequest], - gcdc_transition_route_group.TransitionRouteGroup]: - # 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._CreateTransitionRouteGroup(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_transition_route_group(self) -> Callable[ - [transition_route_group.DeleteTransitionRouteGroupRequest], - 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._DeleteTransitionRouteGroup(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_transition_route_group(self) -> Callable[ - [transition_route_group.GetTransitionRouteGroupRequest], - transition_route_group.TransitionRouteGroup]: - # 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._GetTransitionRouteGroup(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_transition_route_groups(self) -> Callable[ - [transition_route_group.ListTransitionRouteGroupsRequest], - transition_route_group.ListTransitionRouteGroupsResponse]: - # 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._ListTransitionRouteGroups(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_transition_route_group(self) -> Callable[ - [gcdc_transition_route_group.UpdateTransitionRouteGroupRequest], - gcdc_transition_route_group.TransitionRouteGroup]: - # 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._UpdateTransitionRouteGroup(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_location(self): - return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore - - class _GetLocation(TransitionRouteGroupsRestStub): - def __call__(self, - request: locations_pb2.GetLocationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.Location: - - r"""Call the get location method over HTTP. - - Args: - request (locations_pb2.GetLocationRequest): - The request object for GetLocation 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: - locations_pb2.Location: Response from GetLocation method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*}', - }, - ] - - request, metadata = self._interceptor.pre_get_location(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 = locations_pb2.Location() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_get_location(resp) - return resp - - @property - def list_locations(self): - return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore - - class _ListLocations(TransitionRouteGroupsRestStub): - def __call__(self, - request: locations_pb2.ListLocationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.ListLocationsResponse: - - r"""Call the list locations method over HTTP. - - Args: - request (locations_pb2.ListLocationsRequest): - The request object for ListLocations 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: - locations_pb2.ListLocationsResponse: Response from ListLocations method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*}/locations', - }, - ] - - request, metadata = self._interceptor.pre_list_locations(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 = locations_pb2.ListLocationsResponse() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_list_locations(resp) - return resp - - @property - def cancel_operation(self): - return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore - - class _CancelOperation(TransitionRouteGroupsRestStub): - 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': '/v3/{name=projects/*/operations/*}:cancel', - }, -{ - 'method': 'post', - 'uri': '/v3/{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(TransitionRouteGroupsRestStub): - 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': '/v3/{name=projects/*/operations/*}', - }, -{ - 'method': 'get', - 'uri': '/v3/{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(TransitionRouteGroupsRestStub): - 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': '/v3/{name=projects/*}/operations', - }, -{ - 'method': 'get', - 'uri': '/v3/{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__=( - 'TransitionRouteGroupsRestTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/__init__.py deleted file mode 100644 index 841a14ae..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/__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 VersionsClient -from .async_client import VersionsAsyncClient - -__all__ = ( - 'VersionsClient', - 'VersionsAsyncClient', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/async_client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/async_client.py deleted file mode 100644 index 9e24918e..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/async_client.py +++ /dev/null @@ -1,1270 +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.dialogflowcx_v3 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.dialogflowcx_v3.services.versions import pagers -from google.cloud.dialogflowcx_v3.types import flow -from google.cloud.dialogflowcx_v3.types import version -from google.cloud.dialogflowcx_v3.types import version as gcdc_version -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import struct_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import VersionsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import VersionsGrpcAsyncIOTransport -from .client import VersionsClient - - -class VersionsAsyncClient: - """Service for managing - [Versions][google.cloud.dialogflow.cx.v3.Version]. - """ - - _client: VersionsClient - - DEFAULT_ENDPOINT = VersionsClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = VersionsClient.DEFAULT_MTLS_ENDPOINT - - version_path = staticmethod(VersionsClient.version_path) - parse_version_path = staticmethod(VersionsClient.parse_version_path) - common_billing_account_path = staticmethod(VersionsClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(VersionsClient.parse_common_billing_account_path) - common_folder_path = staticmethod(VersionsClient.common_folder_path) - parse_common_folder_path = staticmethod(VersionsClient.parse_common_folder_path) - common_organization_path = staticmethod(VersionsClient.common_organization_path) - parse_common_organization_path = staticmethod(VersionsClient.parse_common_organization_path) - common_project_path = staticmethod(VersionsClient.common_project_path) - parse_common_project_path = staticmethod(VersionsClient.parse_common_project_path) - common_location_path = staticmethod(VersionsClient.common_location_path) - parse_common_location_path = staticmethod(VersionsClient.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: - VersionsAsyncClient: The constructed client. - """ - return VersionsClient.from_service_account_info.__func__(VersionsAsyncClient, 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: - VersionsAsyncClient: The constructed client. - """ - return VersionsClient.from_service_account_file.__func__(VersionsAsyncClient, 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 VersionsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> VersionsTransport: - """Returns the transport used by the client instance. - - Returns: - VersionsTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(VersionsClient).get_transport_class, type(VersionsClient)) - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, VersionsTransport] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the versions 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, ~.VersionsTransport]): 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 = VersionsClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def list_versions(self, - request: Optional[Union[version.ListVersionsRequest, 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.ListVersionsAsyncPager: - r"""Returns the list of all versions in the specified - [Flow][google.cloud.dialogflow.cx.v3.Flow]. - - .. 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 dialogflowcx_v3 - - async def sample_list_versions(): - # Create a client - client = dialogflowcx_v3.VersionsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListVersionsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_versions(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ListVersionsRequest, dict]]): - The request object. The request message for - [Versions.ListVersions][google.cloud.dialogflow.cx.v3.Versions.ListVersions]. - parent (:class:`str`): - Required. The [Flow][google.cloud.dialogflow.cx.v3.Flow] - to list all versions for. Format: - ``projects//locations//agents//flows/``. - - 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.dialogflowcx_v3.services.versions.pagers.ListVersionsAsyncPager: - The response message for - [Versions.ListVersions][google.cloud.dialogflow.cx.v3.Versions.ListVersions]. - - 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 = version.ListVersionsRequest(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_versions, - 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.ListVersionsAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_version(self, - request: Optional[Union[version.GetVersionRequest, 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]] = (), - ) -> version.Version: - r"""Retrieves the specified - [Version][google.cloud.dialogflow.cx.v3.Version]. - - .. 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 dialogflowcx_v3 - - async def sample_get_version(): - # Create a client - client = dialogflowcx_v3.VersionsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetVersionRequest( - name="name_value", - ) - - # Make the request - response = await client.get_version(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.GetVersionRequest, dict]]): - The request object. The request message for - [Versions.GetVersion][google.cloud.dialogflow.cx.v3.Versions.GetVersion]. - name (:class:`str`): - Required. The name of the - [Version][google.cloud.dialogflow.cx.v3.Version]. - Format: - ``projects//locations//agents//flows//versions/``. - - 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.dialogflowcx_v3.types.Version: - Represents a version of a flow. - """ - # 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 = version.GetVersionRequest(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_version, - 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 create_version(self, - request: Optional[Union[gcdc_version.CreateVersionRequest, dict]] = None, - *, - parent: Optional[str] = None, - version: Optional[gcdc_version.Version] = 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 a [Version][google.cloud.dialogflow.cx.v3.Version] in - the specified [Flow][google.cloud.dialogflow.cx.v3.Flow]. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [CreateVersionOperationMetadata][google.cloud.dialogflow.cx.v3.CreateVersionOperationMetadata] - - ``response``: - [Version][google.cloud.dialogflow.cx.v3.Version] - - .. 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 dialogflowcx_v3 - - async def sample_create_version(): - # Create a client - client = dialogflowcx_v3.VersionsAsyncClient() - - # Initialize request argument(s) - version = dialogflowcx_v3.Version() - version.display_name = "display_name_value" - - request = dialogflowcx_v3.CreateVersionRequest( - parent="parent_value", - version=version, - ) - - # Make the request - operation = client.create_version(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.CreateVersionRequest, dict]]): - The request object. The request message for - [Versions.CreateVersion][google.cloud.dialogflow.cx.v3.Versions.CreateVersion]. - parent (:class:`str`): - Required. The [Flow][google.cloud.dialogflow.cx.v3.Flow] - to create an - [Version][google.cloud.dialogflow.cx.v3.Version] for. - Format: - ``projects//locations//agents//flows/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - version (:class:`google.cloud.dialogflowcx_v3.types.Version`): - Required. The version to create. - This corresponds to the ``version`` 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.dialogflowcx_v3.types.Version` - Represents a version of a flow. - - """ - # 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, version]) - 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 = gcdc_version.CreateVersionRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if version is not None: - request.version = version - - # 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_version, - 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, - gcdc_version.Version, - metadata_type=gcdc_version.CreateVersionOperationMetadata, - ) - - # Done; return the response. - return response - - async def update_version(self, - request: Optional[Union[gcdc_version.UpdateVersionRequest, dict]] = None, - *, - version: Optional[gcdc_version.Version] = 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]] = (), - ) -> gcdc_version.Version: - r"""Updates the specified - [Version][google.cloud.dialogflow.cx.v3.Version]. - - .. 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 dialogflowcx_v3 - - async def sample_update_version(): - # Create a client - client = dialogflowcx_v3.VersionsAsyncClient() - - # Initialize request argument(s) - version = dialogflowcx_v3.Version() - version.display_name = "display_name_value" - - request = dialogflowcx_v3.UpdateVersionRequest( - version=version, - ) - - # Make the request - response = await client.update_version(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.UpdateVersionRequest, dict]]): - The request object. The request message for - [Versions.UpdateVersion][google.cloud.dialogflow.cx.v3.Versions.UpdateVersion]. - version (:class:`google.cloud.dialogflowcx_v3.types.Version`): - Required. The version to update. - This corresponds to the ``version`` 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 mask to control which fields get updated. - Currently only ``description`` and ``display_name`` can - 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.dialogflowcx_v3.types.Version: - Represents a version of a flow. - """ - # 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([version, 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 = gcdc_version.UpdateVersionRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if version is not None: - request.version = version - 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_version, - 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(( - ("version.name", request.version.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_version(self, - request: Optional[Union[version.DeleteVersionRequest, 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 the specified - [Version][google.cloud.dialogflow.cx.v3.Version]. - - .. 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 dialogflowcx_v3 - - async def sample_delete_version(): - # Create a client - client = dialogflowcx_v3.VersionsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteVersionRequest( - name="name_value", - ) - - # Make the request - await client.delete_version(request=request) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.DeleteVersionRequest, dict]]): - The request object. The request message for - [Versions.DeleteVersion][google.cloud.dialogflow.cx.v3.Versions.DeleteVersion]. - name (:class:`str`): - Required. The name of the - [Version][google.cloud.dialogflow.cx.v3.Version] to - delete. Format: - ``projects//locations//agents//flows//versions/``. - - 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 = version.DeleteVersionRequest(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_version, - 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 load_version(self, - request: Optional[Union[version.LoadVersionRequest, 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"""Loads resources in the specified version to the draft flow. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: An `Empty - message `__ - - .. 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 dialogflowcx_v3 - - async def sample_load_version(): - # Create a client - client = dialogflowcx_v3.VersionsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.LoadVersionRequest( - name="name_value", - ) - - # Make the request - operation = client.load_version(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.LoadVersionRequest, dict]]): - The request object. The request message for - [Versions.LoadVersion][google.cloud.dialogflow.cx.v3.Versions.LoadVersion]. - name (:class:`str`): - Required. The - [Version][google.cloud.dialogflow.cx.v3.Version] to be - loaded to draft flow. Format: - ``projects//locations//agents//flows//versions/``. - - 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 = version.LoadVersionRequest(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.load_version, - 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=struct_pb2.Struct, - ) - - # Done; return the response. - return response - - async def compare_versions(self, - request: Optional[Union[version.CompareVersionsRequest, dict]] = None, - *, - base_version: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> version.CompareVersionsResponse: - r"""Compares the specified base version with target - version. - - .. 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 dialogflowcx_v3 - - async def sample_compare_versions(): - # Create a client - client = dialogflowcx_v3.VersionsAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.CompareVersionsRequest( - base_version="base_version_value", - target_version="target_version_value", - ) - - # Make the request - response = await client.compare_versions(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.CompareVersionsRequest, dict]]): - The request object. The request message for - [Versions.CompareVersions][google.cloud.dialogflow.cx.v3.Versions.CompareVersions]. - base_version (:class:`str`): - Required. Name of the base flow version to compare with - the target version. Use version ID ``0`` to indicate the - draft version of the specified flow. - - Format: - ``projects//locations//agents/ /flows//versions/``. - - This corresponds to the ``base_version`` 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.dialogflowcx_v3.types.CompareVersionsResponse: - The response message for - [Versions.CompareVersions][google.cloud.dialogflow.cx.v3.Versions.CompareVersions]. - - """ - # 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([base_version]) - 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 = version.CompareVersionsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if base_version is not None: - request.base_version = base_version - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.compare_versions, - 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(( - ("base_version", request.base_version), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - 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 get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**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_location, - 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_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**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_locations, - 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 __aenter__(self) -> "VersionsAsyncClient": - 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__ = ( - "VersionsAsyncClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/client.py deleted file mode 100644 index b391b029..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/client.py +++ /dev/null @@ -1,1469 +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.dialogflowcx_v3 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.dialogflowcx_v3.services.versions import pagers -from google.cloud.dialogflowcx_v3.types import flow -from google.cloud.dialogflowcx_v3.types import version -from google.cloud.dialogflowcx_v3.types import version as gcdc_version -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import struct_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import VersionsTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import VersionsGrpcTransport -from .transports.grpc_asyncio import VersionsGrpcAsyncIOTransport -from .transports.rest import VersionsRestTransport - - -class VersionsClientMeta(type): - """Metaclass for the Versions 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[VersionsTransport]] - _transport_registry["grpc"] = VersionsGrpcTransport - _transport_registry["grpc_asyncio"] = VersionsGrpcAsyncIOTransport - _transport_registry["rest"] = VersionsRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[VersionsTransport]: - """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 VersionsClient(metaclass=VersionsClientMeta): - """Service for managing - [Versions][google.cloud.dialogflow.cx.v3.Version]. - """ - - @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 = "dialogflow.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: - VersionsClient: 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: - VersionsClient: 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) -> VersionsTransport: - """Returns the transport used by the client instance. - - Returns: - VersionsTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def version_path(project: str,location: str,agent: str,flow: str,version: str,) -> str: - """Returns a fully-qualified version string.""" - return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version}".format(project=project, location=location, agent=agent, flow=flow, version=version, ) - - @staticmethod - def parse_version_path(path: str) -> Dict[str,str]: - """Parses a version path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)/versions/(?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, VersionsTransport]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the versions 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, VersionsTransport]): 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, VersionsTransport): - # transport is a VersionsTransport 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 list_versions(self, - request: Optional[Union[version.ListVersionsRequest, 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.ListVersionsPager: - r"""Returns the list of all versions in the specified - [Flow][google.cloud.dialogflow.cx.v3.Flow]. - - .. 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 dialogflowcx_v3 - - def sample_list_versions(): - # Create a client - client = dialogflowcx_v3.VersionsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListVersionsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_versions(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ListVersionsRequest, dict]): - The request object. The request message for - [Versions.ListVersions][google.cloud.dialogflow.cx.v3.Versions.ListVersions]. - parent (str): - Required. The [Flow][google.cloud.dialogflow.cx.v3.Flow] - to list all versions for. Format: - ``projects//locations//agents//flows/``. - - 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.dialogflowcx_v3.services.versions.pagers.ListVersionsPager: - The response message for - [Versions.ListVersions][google.cloud.dialogflow.cx.v3.Versions.ListVersions]. - - 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 version.ListVersionsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, version.ListVersionsRequest): - request = version.ListVersionsRequest(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_versions] - - # 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.ListVersionsPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_version(self, - request: Optional[Union[version.GetVersionRequest, 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]] = (), - ) -> version.Version: - r"""Retrieves the specified - [Version][google.cloud.dialogflow.cx.v3.Version]. - - .. 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 dialogflowcx_v3 - - def sample_get_version(): - # Create a client - client = dialogflowcx_v3.VersionsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetVersionRequest( - name="name_value", - ) - - # Make the request - response = client.get_version(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.GetVersionRequest, dict]): - The request object. The request message for - [Versions.GetVersion][google.cloud.dialogflow.cx.v3.Versions.GetVersion]. - name (str): - Required. The name of the - [Version][google.cloud.dialogflow.cx.v3.Version]. - Format: - ``projects//locations//agents//flows//versions/``. - - 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.dialogflowcx_v3.types.Version: - Represents a version of a flow. - """ - # 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 version.GetVersionRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, version.GetVersionRequest): - request = version.GetVersionRequest(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_version] - - # 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 create_version(self, - request: Optional[Union[gcdc_version.CreateVersionRequest, dict]] = None, - *, - parent: Optional[str] = None, - version: Optional[gcdc_version.Version] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Creates a [Version][google.cloud.dialogflow.cx.v3.Version] in - the specified [Flow][google.cloud.dialogflow.cx.v3.Flow]. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [CreateVersionOperationMetadata][google.cloud.dialogflow.cx.v3.CreateVersionOperationMetadata] - - ``response``: - [Version][google.cloud.dialogflow.cx.v3.Version] - - .. 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 dialogflowcx_v3 - - def sample_create_version(): - # Create a client - client = dialogflowcx_v3.VersionsClient() - - # Initialize request argument(s) - version = dialogflowcx_v3.Version() - version.display_name = "display_name_value" - - request = dialogflowcx_v3.CreateVersionRequest( - parent="parent_value", - version=version, - ) - - # Make the request - operation = client.create_version(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.CreateVersionRequest, dict]): - The request object. The request message for - [Versions.CreateVersion][google.cloud.dialogflow.cx.v3.Versions.CreateVersion]. - parent (str): - Required. The [Flow][google.cloud.dialogflow.cx.v3.Flow] - to create an - [Version][google.cloud.dialogflow.cx.v3.Version] for. - Format: - ``projects//locations//agents//flows/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - version (google.cloud.dialogflowcx_v3.types.Version): - Required. The version to create. - This corresponds to the ``version`` 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.dialogflowcx_v3.types.Version` - Represents a version of a flow. - - """ - # 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, version]) - 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 gcdc_version.CreateVersionRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_version.CreateVersionRequest): - request = gcdc_version.CreateVersionRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if version is not None: - request.version = version - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_version] - - # 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, - gcdc_version.Version, - metadata_type=gcdc_version.CreateVersionOperationMetadata, - ) - - # Done; return the response. - return response - - def update_version(self, - request: Optional[Union[gcdc_version.UpdateVersionRequest, dict]] = None, - *, - version: Optional[gcdc_version.Version] = 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]] = (), - ) -> gcdc_version.Version: - r"""Updates the specified - [Version][google.cloud.dialogflow.cx.v3.Version]. - - .. 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 dialogflowcx_v3 - - def sample_update_version(): - # Create a client - client = dialogflowcx_v3.VersionsClient() - - # Initialize request argument(s) - version = dialogflowcx_v3.Version() - version.display_name = "display_name_value" - - request = dialogflowcx_v3.UpdateVersionRequest( - version=version, - ) - - # Make the request - response = client.update_version(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.UpdateVersionRequest, dict]): - The request object. The request message for - [Versions.UpdateVersion][google.cloud.dialogflow.cx.v3.Versions.UpdateVersion]. - version (google.cloud.dialogflowcx_v3.types.Version): - Required. The version to update. - This corresponds to the ``version`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The mask to control which fields get updated. - Currently only ``description`` and ``display_name`` can - 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.dialogflowcx_v3.types.Version: - Represents a version of a flow. - """ - # 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([version, 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 gcdc_version.UpdateVersionRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_version.UpdateVersionRequest): - request = gcdc_version.UpdateVersionRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if version is not None: - request.version = version - 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_version] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("version.name", request.version.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_version(self, - request: Optional[Union[version.DeleteVersionRequest, 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 the specified - [Version][google.cloud.dialogflow.cx.v3.Version]. - - .. 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 dialogflowcx_v3 - - def sample_delete_version(): - # Create a client - client = dialogflowcx_v3.VersionsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteVersionRequest( - name="name_value", - ) - - # Make the request - client.delete_version(request=request) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.DeleteVersionRequest, dict]): - The request object. The request message for - [Versions.DeleteVersion][google.cloud.dialogflow.cx.v3.Versions.DeleteVersion]. - name (str): - Required. The name of the - [Version][google.cloud.dialogflow.cx.v3.Version] to - delete. Format: - ``projects//locations//agents//flows//versions/``. - - 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 version.DeleteVersionRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, version.DeleteVersionRequest): - request = version.DeleteVersionRequest(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_version] - - # 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 load_version(self, - request: Optional[Union[version.LoadVersionRequest, 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"""Loads resources in the specified version to the draft flow. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: An `Empty - message `__ - - .. 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 dialogflowcx_v3 - - def sample_load_version(): - # Create a client - client = dialogflowcx_v3.VersionsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.LoadVersionRequest( - name="name_value", - ) - - # Make the request - operation = client.load_version(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.LoadVersionRequest, dict]): - The request object. The request message for - [Versions.LoadVersion][google.cloud.dialogflow.cx.v3.Versions.LoadVersion]. - name (str): - Required. The - [Version][google.cloud.dialogflow.cx.v3.Version] to be - loaded to draft flow. Format: - ``projects//locations//agents//flows//versions/``. - - 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 version.LoadVersionRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, version.LoadVersionRequest): - request = version.LoadVersionRequest(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.load_version] - - # 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=struct_pb2.Struct, - ) - - # Done; return the response. - return response - - def compare_versions(self, - request: Optional[Union[version.CompareVersionsRequest, dict]] = None, - *, - base_version: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> version.CompareVersionsResponse: - r"""Compares the specified base version with target - version. - - .. 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 dialogflowcx_v3 - - def sample_compare_versions(): - # Create a client - client = dialogflowcx_v3.VersionsClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.CompareVersionsRequest( - base_version="base_version_value", - target_version="target_version_value", - ) - - # Make the request - response = client.compare_versions(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.CompareVersionsRequest, dict]): - The request object. The request message for - [Versions.CompareVersions][google.cloud.dialogflow.cx.v3.Versions.CompareVersions]. - base_version (str): - Required. Name of the base flow version to compare with - the target version. Use version ID ``0`` to indicate the - draft version of the specified flow. - - Format: - ``projects//locations//agents/ /flows//versions/``. - - This corresponds to the ``base_version`` 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.dialogflowcx_v3.types.CompareVersionsResponse: - The response message for - [Versions.CompareVersions][google.cloud.dialogflow.cx.v3.Versions.CompareVersions]. - - """ - # 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([base_version]) - 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 version.CompareVersionsRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, version.CompareVersionsRequest): - request = version.CompareVersionsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if base_version is not None: - request.base_version = base_version - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.compare_versions] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("base_version", request.base_version), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def __enter__(self) -> "VersionsClient": - 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,) - - def get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.get_location, - 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 list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.list_locations, - 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 - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "VersionsClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/pagers.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/pagers.py deleted file mode 100644 index 2e17ddcf..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/pagers.py +++ /dev/null @@ -1,139 +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.dialogflowcx_v3.types import version - - -class ListVersionsPager: - """A pager for iterating through ``list_versions`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListVersionsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``versions`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListVersions`` requests and continue to iterate - through the ``versions`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListVersionsResponse` - 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[..., version.ListVersionsResponse], - request: version.ListVersionsRequest, - response: version.ListVersionsResponse, - *, - 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.dialogflowcx_v3.types.ListVersionsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListVersionsResponse): - 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 = version.ListVersionsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[version.ListVersionsResponse]: - 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[version.Version]: - for page in self.pages: - yield from page.versions - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListVersionsAsyncPager: - """A pager for iterating through ``list_versions`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListVersionsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``versions`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListVersions`` requests and continue to iterate - through the ``versions`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListVersionsResponse` - 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[version.ListVersionsResponse]], - request: version.ListVersionsRequest, - response: version.ListVersionsResponse, - *, - 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.dialogflowcx_v3.types.ListVersionsRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListVersionsResponse): - 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 = version.ListVersionsRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[version.ListVersionsResponse]: - 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[version.Version]: - async def async_generator(): - async for page in self.pages: - for response in page.versions: - 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/v3/google/cloud/dialogflowcx_v3/services/versions/transports/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/transports/__init__.py deleted file mode 100644 index e329760c..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/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 VersionsTransport -from .grpc import VersionsGrpcTransport -from .grpc_asyncio import VersionsGrpcAsyncIOTransport -from .rest import VersionsRestTransport -from .rest import VersionsRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[VersionsTransport]] -_transport_registry['grpc'] = VersionsGrpcTransport -_transport_registry['grpc_asyncio'] = VersionsGrpcAsyncIOTransport -_transport_registry['rest'] = VersionsRestTransport - -__all__ = ( - 'VersionsTransport', - 'VersionsGrpcTransport', - 'VersionsGrpcAsyncIOTransport', - 'VersionsRestTransport', - 'VersionsRestInterceptor', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/transports/base.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/transports/base.py deleted file mode 100644 index 05d0a02f..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/transports/base.py +++ /dev/null @@ -1,287 +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.dialogflowcx_v3 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.dialogflowcx_v3.types import version -from google.cloud.dialogflowcx_v3.types import version as gcdc_version -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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 VersionsTransport(abc.ABC): - """Abstract transport class for Versions.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/dialogflow', - ) - - DEFAULT_HOST: str = 'dialogflow.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.list_versions: gapic_v1.method.wrap_method( - self.list_versions, - default_timeout=None, - client_info=client_info, - ), - self.get_version: gapic_v1.method.wrap_method( - self.get_version, - default_timeout=None, - client_info=client_info, - ), - self.create_version: gapic_v1.method.wrap_method( - self.create_version, - default_timeout=None, - client_info=client_info, - ), - self.update_version: gapic_v1.method.wrap_method( - self.update_version, - default_timeout=None, - client_info=client_info, - ), - self.delete_version: gapic_v1.method.wrap_method( - self.delete_version, - default_timeout=None, - client_info=client_info, - ), - self.load_version: gapic_v1.method.wrap_method( - self.load_version, - default_timeout=None, - client_info=client_info, - ), - self.compare_versions: gapic_v1.method.wrap_method( - self.compare_versions, - 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 list_versions(self) -> Callable[ - [version.ListVersionsRequest], - Union[ - version.ListVersionsResponse, - Awaitable[version.ListVersionsResponse] - ]]: - raise NotImplementedError() - - @property - def get_version(self) -> Callable[ - [version.GetVersionRequest], - Union[ - version.Version, - Awaitable[version.Version] - ]]: - raise NotImplementedError() - - @property - def create_version(self) -> Callable[ - [gcdc_version.CreateVersionRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_version(self) -> Callable[ - [gcdc_version.UpdateVersionRequest], - Union[ - gcdc_version.Version, - Awaitable[gcdc_version.Version] - ]]: - raise NotImplementedError() - - @property - def delete_version(self) -> Callable[ - [version.DeleteVersionRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def load_version(self) -> Callable[ - [version.LoadVersionRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def compare_versions(self) -> Callable[ - [version.CompareVersionsRequest], - Union[ - version.CompareVersionsResponse, - Awaitable[version.CompareVersionsResponse] - ]]: - 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 get_location(self, - ) -> Callable[ - [locations_pb2.GetLocationRequest], - Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], - ]: - raise NotImplementedError() - - @property - def list_locations(self, - ) -> Callable[ - [locations_pb2.ListLocationsRequest], - Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'VersionsTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/transports/grpc.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/transports/grpc.py deleted file mode 100644 index 1ab0be33..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/transports/grpc.py +++ /dev/null @@ -1,560 +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.dialogflowcx_v3.types import version -from google.cloud.dialogflowcx_v3.types import version as gcdc_version -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import VersionsTransport, DEFAULT_CLIENT_INFO - - -class VersionsGrpcTransport(VersionsTransport): - """gRPC backend transport for Versions. - - Service for managing - [Versions][google.cloud.dialogflow.cx.v3.Version]. - - 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 = 'dialogflow.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 = 'dialogflow.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 list_versions(self) -> Callable[ - [version.ListVersionsRequest], - version.ListVersionsResponse]: - r"""Return a callable for the list versions method over gRPC. - - Returns the list of all versions in the specified - [Flow][google.cloud.dialogflow.cx.v3.Flow]. - - Returns: - Callable[[~.ListVersionsRequest], - ~.ListVersionsResponse]: - 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_versions' not in self._stubs: - self._stubs['list_versions'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Versions/ListVersions', - request_serializer=version.ListVersionsRequest.serialize, - response_deserializer=version.ListVersionsResponse.deserialize, - ) - return self._stubs['list_versions'] - - @property - def get_version(self) -> Callable[ - [version.GetVersionRequest], - version.Version]: - r"""Return a callable for the get version method over gRPC. - - Retrieves the specified - [Version][google.cloud.dialogflow.cx.v3.Version]. - - Returns: - Callable[[~.GetVersionRequest], - ~.Version]: - 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_version' not in self._stubs: - self._stubs['get_version'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Versions/GetVersion', - request_serializer=version.GetVersionRequest.serialize, - response_deserializer=version.Version.deserialize, - ) - return self._stubs['get_version'] - - @property - def create_version(self) -> Callable[ - [gcdc_version.CreateVersionRequest], - operations_pb2.Operation]: - r"""Return a callable for the create version method over gRPC. - - Creates a [Version][google.cloud.dialogflow.cx.v3.Version] in - the specified [Flow][google.cloud.dialogflow.cx.v3.Flow]. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [CreateVersionOperationMetadata][google.cloud.dialogflow.cx.v3.CreateVersionOperationMetadata] - - ``response``: - [Version][google.cloud.dialogflow.cx.v3.Version] - - Returns: - Callable[[~.CreateVersionRequest], - ~.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_version' not in self._stubs: - self._stubs['create_version'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Versions/CreateVersion', - request_serializer=gcdc_version.CreateVersionRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_version'] - - @property - def update_version(self) -> Callable[ - [gcdc_version.UpdateVersionRequest], - gcdc_version.Version]: - r"""Return a callable for the update version method over gRPC. - - Updates the specified - [Version][google.cloud.dialogflow.cx.v3.Version]. - - Returns: - Callable[[~.UpdateVersionRequest], - ~.Version]: - 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_version' not in self._stubs: - self._stubs['update_version'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Versions/UpdateVersion', - request_serializer=gcdc_version.UpdateVersionRequest.serialize, - response_deserializer=gcdc_version.Version.deserialize, - ) - return self._stubs['update_version'] - - @property - def delete_version(self) -> Callable[ - [version.DeleteVersionRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete version method over gRPC. - - Deletes the specified - [Version][google.cloud.dialogflow.cx.v3.Version]. - - Returns: - Callable[[~.DeleteVersionRequest], - ~.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_version' not in self._stubs: - self._stubs['delete_version'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Versions/DeleteVersion', - request_serializer=version.DeleteVersionRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_version'] - - @property - def load_version(self) -> Callable[ - [version.LoadVersionRequest], - operations_pb2.Operation]: - r"""Return a callable for the load version method over gRPC. - - Loads resources in the specified version to the draft flow. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: An `Empty - message `__ - - Returns: - Callable[[~.LoadVersionRequest], - ~.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 'load_version' not in self._stubs: - self._stubs['load_version'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Versions/LoadVersion', - request_serializer=version.LoadVersionRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['load_version'] - - @property - def compare_versions(self) -> Callable[ - [version.CompareVersionsRequest], - version.CompareVersionsResponse]: - r"""Return a callable for the compare versions method over gRPC. - - Compares the specified base version with target - version. - - Returns: - Callable[[~.CompareVersionsRequest], - ~.CompareVersionsResponse]: - 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 'compare_versions' not in self._stubs: - self._stubs['compare_versions'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Versions/CompareVersions', - request_serializer=version.CompareVersionsRequest.serialize, - response_deserializer=version.CompareVersionsResponse.deserialize, - ) - return self._stubs['compare_versions'] - - 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 list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'VersionsGrpcTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/transports/grpc_asyncio.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/transports/grpc_asyncio.py deleted file mode 100644 index 055cb4fa..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/transports/grpc_asyncio.py +++ /dev/null @@ -1,559 +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.dialogflowcx_v3.types import version -from google.cloud.dialogflowcx_v3.types import version as gcdc_version -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import VersionsTransport, DEFAULT_CLIENT_INFO -from .grpc import VersionsGrpcTransport - - -class VersionsGrpcAsyncIOTransport(VersionsTransport): - """gRPC AsyncIO backend transport for Versions. - - Service for managing - [Versions][google.cloud.dialogflow.cx.v3.Version]. - - 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 = 'dialogflow.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 = 'dialogflow.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 list_versions(self) -> Callable[ - [version.ListVersionsRequest], - Awaitable[version.ListVersionsResponse]]: - r"""Return a callable for the list versions method over gRPC. - - Returns the list of all versions in the specified - [Flow][google.cloud.dialogflow.cx.v3.Flow]. - - Returns: - Callable[[~.ListVersionsRequest], - Awaitable[~.ListVersionsResponse]]: - 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_versions' not in self._stubs: - self._stubs['list_versions'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Versions/ListVersions', - request_serializer=version.ListVersionsRequest.serialize, - response_deserializer=version.ListVersionsResponse.deserialize, - ) - return self._stubs['list_versions'] - - @property - def get_version(self) -> Callable[ - [version.GetVersionRequest], - Awaitable[version.Version]]: - r"""Return a callable for the get version method over gRPC. - - Retrieves the specified - [Version][google.cloud.dialogflow.cx.v3.Version]. - - Returns: - Callable[[~.GetVersionRequest], - Awaitable[~.Version]]: - 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_version' not in self._stubs: - self._stubs['get_version'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Versions/GetVersion', - request_serializer=version.GetVersionRequest.serialize, - response_deserializer=version.Version.deserialize, - ) - return self._stubs['get_version'] - - @property - def create_version(self) -> Callable[ - [gcdc_version.CreateVersionRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create version method over gRPC. - - Creates a [Version][google.cloud.dialogflow.cx.v3.Version] in - the specified [Flow][google.cloud.dialogflow.cx.v3.Flow]. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: - [CreateVersionOperationMetadata][google.cloud.dialogflow.cx.v3.CreateVersionOperationMetadata] - - ``response``: - [Version][google.cloud.dialogflow.cx.v3.Version] - - Returns: - Callable[[~.CreateVersionRequest], - 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_version' not in self._stubs: - self._stubs['create_version'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Versions/CreateVersion', - request_serializer=gcdc_version.CreateVersionRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_version'] - - @property - def update_version(self) -> Callable[ - [gcdc_version.UpdateVersionRequest], - Awaitable[gcdc_version.Version]]: - r"""Return a callable for the update version method over gRPC. - - Updates the specified - [Version][google.cloud.dialogflow.cx.v3.Version]. - - Returns: - Callable[[~.UpdateVersionRequest], - Awaitable[~.Version]]: - 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_version' not in self._stubs: - self._stubs['update_version'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Versions/UpdateVersion', - request_serializer=gcdc_version.UpdateVersionRequest.serialize, - response_deserializer=gcdc_version.Version.deserialize, - ) - return self._stubs['update_version'] - - @property - def delete_version(self) -> Callable[ - [version.DeleteVersionRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete version method over gRPC. - - Deletes the specified - [Version][google.cloud.dialogflow.cx.v3.Version]. - - Returns: - Callable[[~.DeleteVersionRequest], - 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_version' not in self._stubs: - self._stubs['delete_version'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Versions/DeleteVersion', - request_serializer=version.DeleteVersionRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_version'] - - @property - def load_version(self) -> Callable[ - [version.LoadVersionRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the load version method over gRPC. - - Loads resources in the specified version to the draft flow. - - This method is a `long-running - operation `__. - The returned ``Operation`` type has the following - method-specific fields: - - - ``metadata``: An empty `Struct - message `__ - - ``response``: An `Empty - message `__ - - Returns: - Callable[[~.LoadVersionRequest], - 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 'load_version' not in self._stubs: - self._stubs['load_version'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Versions/LoadVersion', - request_serializer=version.LoadVersionRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['load_version'] - - @property - def compare_versions(self) -> Callable[ - [version.CompareVersionsRequest], - Awaitable[version.CompareVersionsResponse]]: - r"""Return a callable for the compare versions method over gRPC. - - Compares the specified base version with target - version. - - Returns: - Callable[[~.CompareVersionsRequest], - Awaitable[~.CompareVersionsResponse]]: - 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 'compare_versions' not in self._stubs: - self._stubs['compare_versions'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Versions/CompareVersions', - request_serializer=version.CompareVersionsRequest.serialize, - response_deserializer=version.CompareVersionsResponse.deserialize, - ) - return self._stubs['compare_versions'] - - 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"] - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - -__all__ = ( - 'VersionsGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/transports/rest.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/transports/rest.py deleted file mode 100644 index 9812fa65..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/versions/transports/rest.py +++ /dev/null @@ -1,1468 +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 google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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.dialogflowcx_v3.types import version -from google.cloud.dialogflowcx_v3.types import version as gcdc_version -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore - -from .base import VersionsTransport, 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 VersionsRestInterceptor: - """Interceptor for Versions. - - 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 VersionsRestTransport. - - .. code-block:: python - class MyCustomVersionsInterceptor(VersionsRestInterceptor): - def pre_compare_versions(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_compare_versions(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_version(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_version(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_version(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_get_version(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_version(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_versions(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_versions(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_load_version(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_load_version(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_version(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_version(self, response): - logging.log(f"Received response: {response}") - return response - - transport = VersionsRestTransport(interceptor=MyCustomVersionsInterceptor()) - client = VersionsClient(transport=transport) - - - """ - def pre_compare_versions(self, request: version.CompareVersionsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[version.CompareVersionsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for compare_versions - - Override in a subclass to manipulate the request or metadata - before they are sent to the Versions server. - """ - return request, metadata - - def post_compare_versions(self, response: version.CompareVersionsResponse) -> version.CompareVersionsResponse: - """Post-rpc interceptor for compare_versions - - Override in a subclass to manipulate the response - after it is returned by the Versions server but before - it is returned to user code. - """ - return response - def pre_create_version(self, request: gcdc_version.CreateVersionRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_version.CreateVersionRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_version - - Override in a subclass to manipulate the request or metadata - before they are sent to the Versions server. - """ - return request, metadata - - def post_create_version(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for create_version - - Override in a subclass to manipulate the response - after it is returned by the Versions server but before - it is returned to user code. - """ - return response - def pre_delete_version(self, request: version.DeleteVersionRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[version.DeleteVersionRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_version - - Override in a subclass to manipulate the request or metadata - before they are sent to the Versions server. - """ - return request, metadata - - def pre_get_version(self, request: version.GetVersionRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[version.GetVersionRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_version - - Override in a subclass to manipulate the request or metadata - before they are sent to the Versions server. - """ - return request, metadata - - def post_get_version(self, response: version.Version) -> version.Version: - """Post-rpc interceptor for get_version - - Override in a subclass to manipulate the response - after it is returned by the Versions server but before - it is returned to user code. - """ - return response - def pre_list_versions(self, request: version.ListVersionsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[version.ListVersionsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_versions - - Override in a subclass to manipulate the request or metadata - before they are sent to the Versions server. - """ - return request, metadata - - def post_list_versions(self, response: version.ListVersionsResponse) -> version.ListVersionsResponse: - """Post-rpc interceptor for list_versions - - Override in a subclass to manipulate the response - after it is returned by the Versions server but before - it is returned to user code. - """ - return response - def pre_load_version(self, request: version.LoadVersionRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[version.LoadVersionRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for load_version - - Override in a subclass to manipulate the request or metadata - before they are sent to the Versions server. - """ - return request, metadata - - def post_load_version(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for load_version - - Override in a subclass to manipulate the response - after it is returned by the Versions server but before - it is returned to user code. - """ - return response - def pre_update_version(self, request: gcdc_version.UpdateVersionRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_version.UpdateVersionRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_version - - Override in a subclass to manipulate the request or metadata - before they are sent to the Versions server. - """ - return request, metadata - - def post_update_version(self, response: gcdc_version.Version) -> gcdc_version.Version: - """Post-rpc interceptor for update_version - - Override in a subclass to manipulate the response - after it is returned by the Versions server but before - it is returned to user code. - """ - return response - - def pre_get_location( - self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_location - - Override in a subclass to manipulate the request or metadata - before they are sent to the Versions server. - """ - return request, metadata - - def post_get_location( - self, response: locations_pb2.Location - ) -> locations_pb2.Location: - """Post-rpc interceptor for get_location - - Override in a subclass to manipulate the response - after it is returned by the Versions server but before - it is returned to user code. - """ - return response - def pre_list_locations( - self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_locations - - Override in a subclass to manipulate the request or metadata - before they are sent to the Versions server. - """ - return request, metadata - - def post_list_locations( - self, response: locations_pb2.ListLocationsResponse - ) -> locations_pb2.ListLocationsResponse: - """Post-rpc interceptor for list_locations - - Override in a subclass to manipulate the response - after it is returned by the Versions 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 Versions 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 Versions 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 Versions 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 Versions 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 Versions 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 Versions server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class VersionsRestStub: - _session: AuthorizedSession - _host: str - _interceptor: VersionsRestInterceptor - - -class VersionsRestTransport(VersionsTransport): - """REST backend transport for Versions. - - Service for managing - [Versions][google.cloud.dialogflow.cx.v3.Version]. - - 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 = 'dialogflow.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[VersionsRestInterceptor] = 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 VersionsRestInterceptor() - 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': '/v3/{name=projects/*/operations/*}:cancel', - }, - { - 'method': 'post', - 'uri': '/v3/{name=projects/*/locations/*/operations/*}:cancel', - }, - ], - 'google.longrunning.Operations.GetOperation': [ - { - 'method': 'get', - 'uri': '/v3/{name=projects/*/operations/*}', - }, - { - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/operations/*}', - }, - ], - 'google.longrunning.Operations.ListOperations': [ - { - 'method': 'get', - 'uri': '/v3/{name=projects/*}/operations', - }, - { - 'method': 'get', - 'uri': '/v3/{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="v3") - - self._operations_client = operations_v1.AbstractOperationsClient(transport=rest_transport) - - # Return the client from cache. - return self._operations_client - - class _CompareVersions(VersionsRestStub): - def __hash__(self): - return hash("CompareVersions") - - __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: version.CompareVersionsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> version.CompareVersionsResponse: - r"""Call the compare versions method over HTTP. - - Args: - request (~.version.CompareVersionsRequest): - The request object. The request message for - [Versions.CompareVersions][google.cloud.dialogflow.cx.v3.Versions.CompareVersions]. - 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: - ~.version.CompareVersionsResponse: - The response message for - [Versions.CompareVersions][google.cloud.dialogflow.cx.v3.Versions.CompareVersions]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v3/{base_version=projects/*/locations/*/agents/*/flows/*/versions/*}:compareVersions', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_compare_versions(request, metadata) - pb_request = version.CompareVersionsRequest.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 = version.CompareVersionsResponse() - pb_resp = version.CompareVersionsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_compare_versions(resp) - return resp - - class _CreateVersion(VersionsRestStub): - def __hash__(self): - return hash("CreateVersion") - - __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: gcdc_version.CreateVersionRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the create version method over HTTP. - - Args: - request (~.gcdc_version.CreateVersionRequest): - The request object. The request message for - [Versions.CreateVersion][google.cloud.dialogflow.cx.v3.Versions.CreateVersion]. - 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': '/v3/{parent=projects/*/locations/*/agents/*/flows/*}/versions', - 'body': 'version', - }, - ] - request, metadata = self._interceptor.pre_create_version(request, metadata) - pb_request = gcdc_version.CreateVersionRequest.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_version(resp) - return resp - - class _DeleteVersion(VersionsRestStub): - def __hash__(self): - return hash("DeleteVersion") - - __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: version.DeleteVersionRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete version method over HTTP. - - Args: - request (~.version.DeleteVersionRequest): - The request object. The request message for - [Versions.DeleteVersion][google.cloud.dialogflow.cx.v3.Versions.DeleteVersion]. - 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': '/v3/{name=projects/*/locations/*/agents/*/flows/*/versions/*}', - }, - ] - request, metadata = self._interceptor.pre_delete_version(request, metadata) - pb_request = version.DeleteVersionRequest.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 _GetVersion(VersionsRestStub): - def __hash__(self): - return hash("GetVersion") - - __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: version.GetVersionRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> version.Version: - r"""Call the get version method over HTTP. - - Args: - request (~.version.GetVersionRequest): - The request object. The request message for - [Versions.GetVersion][google.cloud.dialogflow.cx.v3.Versions.GetVersion]. - 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: - ~.version.Version: - Represents a version of a flow. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/flows/*/versions/*}', - }, - ] - request, metadata = self._interceptor.pre_get_version(request, metadata) - pb_request = version.GetVersionRequest.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 = version.Version() - pb_resp = version.Version.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_version(resp) - return resp - - class _ListVersions(VersionsRestStub): - def __hash__(self): - return hash("ListVersions") - - __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: version.ListVersionsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> version.ListVersionsResponse: - r"""Call the list versions method over HTTP. - - Args: - request (~.version.ListVersionsRequest): - The request object. The request message for - [Versions.ListVersions][google.cloud.dialogflow.cx.v3.Versions.ListVersions]. - 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: - ~.version.ListVersionsResponse: - The response message for - [Versions.ListVersions][google.cloud.dialogflow.cx.v3.Versions.ListVersions]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*/flows/*}/versions', - }, - ] - request, metadata = self._interceptor.pre_list_versions(request, metadata) - pb_request = version.ListVersionsRequest.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 = version.ListVersionsResponse() - pb_resp = version.ListVersionsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_versions(resp) - return resp - - class _LoadVersion(VersionsRestStub): - def __hash__(self): - return hash("LoadVersion") - - __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: version.LoadVersionRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the load version method over HTTP. - - Args: - request (~.version.LoadVersionRequest): - The request object. The request message for - [Versions.LoadVersion][google.cloud.dialogflow.cx.v3.Versions.LoadVersion]. - 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': '/v3/{name=projects/*/locations/*/agents/*/flows/*/versions/*}:load', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_load_version(request, metadata) - pb_request = version.LoadVersionRequest.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_load_version(resp) - return resp - - class _UpdateVersion(VersionsRestStub): - def __hash__(self): - return hash("UpdateVersion") - - __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: gcdc_version.UpdateVersionRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_version.Version: - r"""Call the update version method over HTTP. - - Args: - request (~.gcdc_version.UpdateVersionRequest): - The request object. The request message for - [Versions.UpdateVersion][google.cloud.dialogflow.cx.v3.Versions.UpdateVersion]. - 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: - ~.gcdc_version.Version: - Represents a version of a flow. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v3/{version.name=projects/*/locations/*/agents/*/flows/*/versions/*}', - 'body': 'version', - }, - ] - request, metadata = self._interceptor.pre_update_version(request, metadata) - pb_request = gcdc_version.UpdateVersionRequest.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 = gcdc_version.Version() - pb_resp = gcdc_version.Version.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_version(resp) - return resp - - @property - def compare_versions(self) -> Callable[ - [version.CompareVersionsRequest], - version.CompareVersionsResponse]: - # 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._CompareVersions(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_version(self) -> Callable[ - [gcdc_version.CreateVersionRequest], - 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._CreateVersion(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_version(self) -> Callable[ - [version.DeleteVersionRequest], - 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._DeleteVersion(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_version(self) -> Callable[ - [version.GetVersionRequest], - version.Version]: - # 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._GetVersion(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_versions(self) -> Callable[ - [version.ListVersionsRequest], - version.ListVersionsResponse]: - # 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._ListVersions(self._session, self._host, self._interceptor) # type: ignore - - @property - def load_version(self) -> Callable[ - [version.LoadVersionRequest], - 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._LoadVersion(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_version(self) -> Callable[ - [gcdc_version.UpdateVersionRequest], - gcdc_version.Version]: - # 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._UpdateVersion(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_location(self): - return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore - - class _GetLocation(VersionsRestStub): - def __call__(self, - request: locations_pb2.GetLocationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.Location: - - r"""Call the get location method over HTTP. - - Args: - request (locations_pb2.GetLocationRequest): - The request object for GetLocation 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: - locations_pb2.Location: Response from GetLocation method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*}', - }, - ] - - request, metadata = self._interceptor.pre_get_location(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 = locations_pb2.Location() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_get_location(resp) - return resp - - @property - def list_locations(self): - return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore - - class _ListLocations(VersionsRestStub): - def __call__(self, - request: locations_pb2.ListLocationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.ListLocationsResponse: - - r"""Call the list locations method over HTTP. - - Args: - request (locations_pb2.ListLocationsRequest): - The request object for ListLocations 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: - locations_pb2.ListLocationsResponse: Response from ListLocations method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*}/locations', - }, - ] - - request, metadata = self._interceptor.pre_list_locations(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 = locations_pb2.ListLocationsResponse() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_list_locations(resp) - return resp - - @property - def cancel_operation(self): - return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore - - class _CancelOperation(VersionsRestStub): - 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': '/v3/{name=projects/*/operations/*}:cancel', - }, -{ - 'method': 'post', - 'uri': '/v3/{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(VersionsRestStub): - 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': '/v3/{name=projects/*/operations/*}', - }, -{ - 'method': 'get', - 'uri': '/v3/{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(VersionsRestStub): - 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': '/v3/{name=projects/*}/operations', - }, -{ - 'method': 'get', - 'uri': '/v3/{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__=( - 'VersionsRestTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/__init__.py deleted file mode 100644 index 74fd1b23..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/__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 WebhooksClient -from .async_client import WebhooksAsyncClient - -__all__ = ( - 'WebhooksClient', - 'WebhooksAsyncClient', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/async_client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/async_client.py deleted file mode 100644 index f6a3201d..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/async_client.py +++ /dev/null @@ -1,1009 +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.dialogflowcx_v3 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.cloud.dialogflowcx_v3.services.webhooks import pagers -from google.cloud.dialogflowcx_v3.types import webhook -from google.cloud.dialogflowcx_v3.types import webhook as gcdc_webhook -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import WebhooksTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import WebhooksGrpcAsyncIOTransport -from .client import WebhooksClient - - -class WebhooksAsyncClient: - """Service for managing - [Webhooks][google.cloud.dialogflow.cx.v3.Webhook]. - """ - - _client: WebhooksClient - - DEFAULT_ENDPOINT = WebhooksClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = WebhooksClient.DEFAULT_MTLS_ENDPOINT - - service_path = staticmethod(WebhooksClient.service_path) - parse_service_path = staticmethod(WebhooksClient.parse_service_path) - webhook_path = staticmethod(WebhooksClient.webhook_path) - parse_webhook_path = staticmethod(WebhooksClient.parse_webhook_path) - common_billing_account_path = staticmethod(WebhooksClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(WebhooksClient.parse_common_billing_account_path) - common_folder_path = staticmethod(WebhooksClient.common_folder_path) - parse_common_folder_path = staticmethod(WebhooksClient.parse_common_folder_path) - common_organization_path = staticmethod(WebhooksClient.common_organization_path) - parse_common_organization_path = staticmethod(WebhooksClient.parse_common_organization_path) - common_project_path = staticmethod(WebhooksClient.common_project_path) - parse_common_project_path = staticmethod(WebhooksClient.parse_common_project_path) - common_location_path = staticmethod(WebhooksClient.common_location_path) - parse_common_location_path = staticmethod(WebhooksClient.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: - WebhooksAsyncClient: The constructed client. - """ - return WebhooksClient.from_service_account_info.__func__(WebhooksAsyncClient, 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: - WebhooksAsyncClient: The constructed client. - """ - return WebhooksClient.from_service_account_file.__func__(WebhooksAsyncClient, 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 WebhooksClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> WebhooksTransport: - """Returns the transport used by the client instance. - - Returns: - WebhooksTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(WebhooksClient).get_transport_class, type(WebhooksClient)) - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, WebhooksTransport] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the webhooks 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, ~.WebhooksTransport]): 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 = WebhooksClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def list_webhooks(self, - request: Optional[Union[webhook.ListWebhooksRequest, 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.ListWebhooksAsyncPager: - r"""Returns the list of all webhooks in the specified - agent. - - .. 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 dialogflowcx_v3 - - async def sample_list_webhooks(): - # Create a client - client = dialogflowcx_v3.WebhooksAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListWebhooksRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_webhooks(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.ListWebhooksRequest, dict]]): - The request object. The request message for - [Webhooks.ListWebhooks][google.cloud.dialogflow.cx.v3.Webhooks.ListWebhooks]. - parent (:class:`str`): - Required. The agent to list all webhooks for. Format: - ``projects//locations//agents/``. - - 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.dialogflowcx_v3.services.webhooks.pagers.ListWebhooksAsyncPager: - The response message for - [Webhooks.ListWebhooks][google.cloud.dialogflow.cx.v3.Webhooks.ListWebhooks]. - - 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 = webhook.ListWebhooksRequest(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_webhooks, - 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.ListWebhooksAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_webhook(self, - request: Optional[Union[webhook.GetWebhookRequest, 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]] = (), - ) -> webhook.Webhook: - r"""Retrieves the specified webhook. - - .. 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 dialogflowcx_v3 - - async def sample_get_webhook(): - # Create a client - client = dialogflowcx_v3.WebhooksAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetWebhookRequest( - name="name_value", - ) - - # Make the request - response = await client.get_webhook(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.GetWebhookRequest, dict]]): - The request object. The request message for - [Webhooks.GetWebhook][google.cloud.dialogflow.cx.v3.Webhooks.GetWebhook]. - name (:class:`str`): - Required. The name of the webhook. Format: - ``projects//locations//agents//webhooks/``. - - 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.dialogflowcx_v3.types.Webhook: - Webhooks host the developer's - business logic. During a session, - webhooks allow the developer to use the - data extracted by Dialogflow's natural - language processing to generate dynamic - responses, validate collected data, or - trigger actions on the backend. - - """ - # 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 = webhook.GetWebhookRequest(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_webhook, - 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 create_webhook(self, - request: Optional[Union[gcdc_webhook.CreateWebhookRequest, dict]] = None, - *, - parent: Optional[str] = None, - webhook: Optional[gcdc_webhook.Webhook] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_webhook.Webhook: - r"""Creates a webhook in the specified agent. - - .. 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 dialogflowcx_v3 - - async def sample_create_webhook(): - # Create a client - client = dialogflowcx_v3.WebhooksAsyncClient() - - # Initialize request argument(s) - webhook = dialogflowcx_v3.Webhook() - webhook.generic_web_service.uri = "uri_value" - webhook.display_name = "display_name_value" - - request = dialogflowcx_v3.CreateWebhookRequest( - parent="parent_value", - webhook=webhook, - ) - - # Make the request - response = await client.create_webhook(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.CreateWebhookRequest, dict]]): - The request object. The request message for - [Webhooks.CreateWebhook][google.cloud.dialogflow.cx.v3.Webhooks.CreateWebhook]. - parent (:class:`str`): - Required. The agent to create a webhook for. Format: - ``projects//locations//agents/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - webhook (:class:`google.cloud.dialogflowcx_v3.types.Webhook`): - Required. The webhook to create. - This corresponds to the ``webhook`` 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.dialogflowcx_v3.types.Webhook: - Webhooks host the developer's - business logic. During a session, - webhooks allow the developer to use the - data extracted by Dialogflow's natural - language processing to generate dynamic - responses, validate collected data, or - trigger actions on the backend. - - """ - # 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, webhook]) - 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 = gcdc_webhook.CreateWebhookRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if webhook is not None: - request.webhook = webhook - - # 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_webhook, - 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_webhook(self, - request: Optional[Union[gcdc_webhook.UpdateWebhookRequest, dict]] = None, - *, - webhook: Optional[gcdc_webhook.Webhook] = 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]] = (), - ) -> gcdc_webhook.Webhook: - r"""Updates the specified webhook. - - .. 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 dialogflowcx_v3 - - async def sample_update_webhook(): - # Create a client - client = dialogflowcx_v3.WebhooksAsyncClient() - - # Initialize request argument(s) - webhook = dialogflowcx_v3.Webhook() - webhook.generic_web_service.uri = "uri_value" - webhook.display_name = "display_name_value" - - request = dialogflowcx_v3.UpdateWebhookRequest( - webhook=webhook, - ) - - # Make the request - response = await client.update_webhook(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.UpdateWebhookRequest, dict]]): - The request object. The request message for - [Webhooks.UpdateWebhook][google.cloud.dialogflow.cx.v3.Webhooks.UpdateWebhook]. - webhook (:class:`google.cloud.dialogflowcx_v3.types.Webhook`): - Required. The webhook to update. - This corresponds to the ``webhook`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The mask to control which fields get - updated. If the mask is not present, all - fields will 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.dialogflowcx_v3.types.Webhook: - Webhooks host the developer's - business logic. During a session, - webhooks allow the developer to use the - data extracted by Dialogflow's natural - language processing to generate dynamic - responses, validate collected data, or - trigger actions on the backend. - - """ - # 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([webhook, 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 = gcdc_webhook.UpdateWebhookRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if webhook is not None: - request.webhook = webhook - 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_webhook, - 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(( - ("webhook.name", request.webhook.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_webhook(self, - request: Optional[Union[webhook.DeleteWebhookRequest, 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 the specified webhook. - - .. 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 dialogflowcx_v3 - - async def sample_delete_webhook(): - # Create a client - client = dialogflowcx_v3.WebhooksAsyncClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteWebhookRequest( - name="name_value", - ) - - # Make the request - await client.delete_webhook(request=request) - - Args: - request (Optional[Union[google.cloud.dialogflowcx_v3.types.DeleteWebhookRequest, dict]]): - The request object. The request message for - [Webhooks.DeleteWebhook][google.cloud.dialogflow.cx.v3.Webhooks.DeleteWebhook]. - name (:class:`str`): - Required. The name of the webhook to delete. Format: - ``projects//locations//agents//webhooks/``. - - 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 = webhook.DeleteWebhookRequest(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_webhook, - 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 get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**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_location, - 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_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**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_locations, - 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 __aenter__(self) -> "WebhooksAsyncClient": - 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__ = ( - "WebhooksAsyncClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/client.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/client.py deleted file mode 100644 index f2b8c819..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/client.py +++ /dev/null @@ -1,1217 +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.dialogflowcx_v3 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.cloud.dialogflowcx_v3.services.webhooks import pagers -from google.cloud.dialogflowcx_v3.types import webhook -from google.cloud.dialogflowcx_v3.types import webhook as gcdc_webhook -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import WebhooksTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import WebhooksGrpcTransport -from .transports.grpc_asyncio import WebhooksGrpcAsyncIOTransport -from .transports.rest import WebhooksRestTransport - - -class WebhooksClientMeta(type): - """Metaclass for the Webhooks 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[WebhooksTransport]] - _transport_registry["grpc"] = WebhooksGrpcTransport - _transport_registry["grpc_asyncio"] = WebhooksGrpcAsyncIOTransport - _transport_registry["rest"] = WebhooksRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[WebhooksTransport]: - """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 WebhooksClient(metaclass=WebhooksClientMeta): - """Service for managing - [Webhooks][google.cloud.dialogflow.cx.v3.Webhook]. - """ - - @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 = "dialogflow.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: - WebhooksClient: 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: - WebhooksClient: 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) -> WebhooksTransport: - """Returns the transport used by the client instance. - - Returns: - WebhooksTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def service_path(project: str,location: str,namespace: str,service: str,) -> str: - """Returns a fully-qualified service string.""" - return "projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}".format(project=project, location=location, namespace=namespace, service=service, ) - - @staticmethod - def parse_service_path(path: str) -> Dict[str,str]: - """Parses a service path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/namespaces/(?P.+?)/services/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def webhook_path(project: str,location: str,agent: str,webhook: str,) -> str: - """Returns a fully-qualified webhook string.""" - return "projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}".format(project=project, location=location, agent=agent, webhook=webhook, ) - - @staticmethod - def parse_webhook_path(path: str) -> Dict[str,str]: - """Parses a webhook path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/webhooks/(?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, WebhooksTransport]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the webhooks 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, WebhooksTransport]): 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, WebhooksTransport): - # transport is a WebhooksTransport 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 list_webhooks(self, - request: Optional[Union[webhook.ListWebhooksRequest, 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.ListWebhooksPager: - r"""Returns the list of all webhooks in the specified - agent. - - .. 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 dialogflowcx_v3 - - def sample_list_webhooks(): - # Create a client - client = dialogflowcx_v3.WebhooksClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.ListWebhooksRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_webhooks(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.ListWebhooksRequest, dict]): - The request object. The request message for - [Webhooks.ListWebhooks][google.cloud.dialogflow.cx.v3.Webhooks.ListWebhooks]. - parent (str): - Required. The agent to list all webhooks for. Format: - ``projects//locations//agents/``. - - 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.dialogflowcx_v3.services.webhooks.pagers.ListWebhooksPager: - The response message for - [Webhooks.ListWebhooks][google.cloud.dialogflow.cx.v3.Webhooks.ListWebhooks]. - - 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 webhook.ListWebhooksRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, webhook.ListWebhooksRequest): - request = webhook.ListWebhooksRequest(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_webhooks] - - # 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.ListWebhooksPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_webhook(self, - request: Optional[Union[webhook.GetWebhookRequest, 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]] = (), - ) -> webhook.Webhook: - r"""Retrieves the specified webhook. - - .. 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 dialogflowcx_v3 - - def sample_get_webhook(): - # Create a client - client = dialogflowcx_v3.WebhooksClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.GetWebhookRequest( - name="name_value", - ) - - # Make the request - response = client.get_webhook(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.GetWebhookRequest, dict]): - The request object. The request message for - [Webhooks.GetWebhook][google.cloud.dialogflow.cx.v3.Webhooks.GetWebhook]. - name (str): - Required. The name of the webhook. Format: - ``projects//locations//agents//webhooks/``. - - 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.dialogflowcx_v3.types.Webhook: - Webhooks host the developer's - business logic. During a session, - webhooks allow the developer to use the - data extracted by Dialogflow's natural - language processing to generate dynamic - responses, validate collected data, or - trigger actions on the backend. - - """ - # 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 webhook.GetWebhookRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, webhook.GetWebhookRequest): - request = webhook.GetWebhookRequest(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_webhook] - - # 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 create_webhook(self, - request: Optional[Union[gcdc_webhook.CreateWebhookRequest, dict]] = None, - *, - parent: Optional[str] = None, - webhook: Optional[gcdc_webhook.Webhook] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gcdc_webhook.Webhook: - r"""Creates a webhook in the specified agent. - - .. 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 dialogflowcx_v3 - - def sample_create_webhook(): - # Create a client - client = dialogflowcx_v3.WebhooksClient() - - # Initialize request argument(s) - webhook = dialogflowcx_v3.Webhook() - webhook.generic_web_service.uri = "uri_value" - webhook.display_name = "display_name_value" - - request = dialogflowcx_v3.CreateWebhookRequest( - parent="parent_value", - webhook=webhook, - ) - - # Make the request - response = client.create_webhook(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.CreateWebhookRequest, dict]): - The request object. The request message for - [Webhooks.CreateWebhook][google.cloud.dialogflow.cx.v3.Webhooks.CreateWebhook]. - parent (str): - Required. The agent to create a webhook for. Format: - ``projects//locations//agents/``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - webhook (google.cloud.dialogflowcx_v3.types.Webhook): - Required. The webhook to create. - This corresponds to the ``webhook`` 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.dialogflowcx_v3.types.Webhook: - Webhooks host the developer's - business logic. During a session, - webhooks allow the developer to use the - data extracted by Dialogflow's natural - language processing to generate dynamic - responses, validate collected data, or - trigger actions on the backend. - - """ - # 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, webhook]) - 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 gcdc_webhook.CreateWebhookRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_webhook.CreateWebhookRequest): - request = gcdc_webhook.CreateWebhookRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if webhook is not None: - request.webhook = webhook - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_webhook] - - # 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_webhook(self, - request: Optional[Union[gcdc_webhook.UpdateWebhookRequest, dict]] = None, - *, - webhook: Optional[gcdc_webhook.Webhook] = 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]] = (), - ) -> gcdc_webhook.Webhook: - r"""Updates the specified webhook. - - .. 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 dialogflowcx_v3 - - def sample_update_webhook(): - # Create a client - client = dialogflowcx_v3.WebhooksClient() - - # Initialize request argument(s) - webhook = dialogflowcx_v3.Webhook() - webhook.generic_web_service.uri = "uri_value" - webhook.display_name = "display_name_value" - - request = dialogflowcx_v3.UpdateWebhookRequest( - webhook=webhook, - ) - - # Make the request - response = client.update_webhook(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.UpdateWebhookRequest, dict]): - The request object. The request message for - [Webhooks.UpdateWebhook][google.cloud.dialogflow.cx.v3.Webhooks.UpdateWebhook]. - webhook (google.cloud.dialogflowcx_v3.types.Webhook): - Required. The webhook to update. - This corresponds to the ``webhook`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The mask to control which fields get - updated. If the mask is not present, all - fields will 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.dialogflowcx_v3.types.Webhook: - Webhooks host the developer's - business logic. During a session, - webhooks allow the developer to use the - data extracted by Dialogflow's natural - language processing to generate dynamic - responses, validate collected data, or - trigger actions on the backend. - - """ - # 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([webhook, 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 gcdc_webhook.UpdateWebhookRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, gcdc_webhook.UpdateWebhookRequest): - request = gcdc_webhook.UpdateWebhookRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if webhook is not None: - request.webhook = webhook - 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_webhook] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("webhook.name", request.webhook.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_webhook(self, - request: Optional[Union[webhook.DeleteWebhookRequest, 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 the specified webhook. - - .. 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 dialogflowcx_v3 - - def sample_delete_webhook(): - # Create a client - client = dialogflowcx_v3.WebhooksClient() - - # Initialize request argument(s) - request = dialogflowcx_v3.DeleteWebhookRequest( - name="name_value", - ) - - # Make the request - client.delete_webhook(request=request) - - Args: - request (Union[google.cloud.dialogflowcx_v3.types.DeleteWebhookRequest, dict]): - The request object. The request message for - [Webhooks.DeleteWebhook][google.cloud.dialogflow.cx.v3.Webhooks.DeleteWebhook]. - name (str): - Required. The name of the webhook to delete. Format: - ``projects//locations//agents//webhooks/``. - - 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 webhook.DeleteWebhookRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, webhook.DeleteWebhookRequest): - request = webhook.DeleteWebhookRequest(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_webhook] - - # 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) -> "WebhooksClient": - 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,) - - def get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.get_location, - 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 list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` 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 = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.list_locations, - 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 - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "WebhooksClient", -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/pagers.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/pagers.py deleted file mode 100644 index 130f1f6d..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/pagers.py +++ /dev/null @@ -1,139 +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.dialogflowcx_v3.types import webhook - - -class ListWebhooksPager: - """A pager for iterating through ``list_webhooks`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListWebhooksResponse` object, and - provides an ``__iter__`` method to iterate through its - ``webhooks`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListWebhooks`` requests and continue to iterate - through the ``webhooks`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListWebhooksResponse` - 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[..., webhook.ListWebhooksResponse], - request: webhook.ListWebhooksRequest, - response: webhook.ListWebhooksResponse, - *, - 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.dialogflowcx_v3.types.ListWebhooksRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListWebhooksResponse): - 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 = webhook.ListWebhooksRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[webhook.ListWebhooksResponse]: - 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[webhook.Webhook]: - for page in self.pages: - yield from page.webhooks - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListWebhooksAsyncPager: - """A pager for iterating through ``list_webhooks`` requests. - - This class thinly wraps an initial - :class:`google.cloud.dialogflowcx_v3.types.ListWebhooksResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``webhooks`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListWebhooks`` requests and continue to iterate - through the ``webhooks`` field on the - corresponding responses. - - All the usual :class:`google.cloud.dialogflowcx_v3.types.ListWebhooksResponse` - 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[webhook.ListWebhooksResponse]], - request: webhook.ListWebhooksRequest, - response: webhook.ListWebhooksResponse, - *, - 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.dialogflowcx_v3.types.ListWebhooksRequest): - The initial request object. - response (google.cloud.dialogflowcx_v3.types.ListWebhooksResponse): - 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 = webhook.ListWebhooksRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[webhook.ListWebhooksResponse]: - 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[webhook.Webhook]: - async def async_generator(): - async for page in self.pages: - for response in page.webhooks: - 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/v3/google/cloud/dialogflowcx_v3/services/webhooks/transports/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/transports/__init__.py deleted file mode 100644 index 0ab90bc2..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/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 WebhooksTransport -from .grpc import WebhooksGrpcTransport -from .grpc_asyncio import WebhooksGrpcAsyncIOTransport -from .rest import WebhooksRestTransport -from .rest import WebhooksRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[WebhooksTransport]] -_transport_registry['grpc'] = WebhooksGrpcTransport -_transport_registry['grpc_asyncio'] = WebhooksGrpcAsyncIOTransport -_transport_registry['rest'] = WebhooksRestTransport - -__all__ = ( - 'WebhooksTransport', - 'WebhooksGrpcTransport', - 'WebhooksGrpcAsyncIOTransport', - 'WebhooksRestTransport', - 'WebhooksRestInterceptor', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/transports/base.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/transports/base.py deleted file mode 100644 index 7729d657..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/transports/base.py +++ /dev/null @@ -1,252 +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.dialogflowcx_v3 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.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.dialogflowcx_v3.types import webhook -from google.cloud.dialogflowcx_v3.types import webhook as gcdc_webhook -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -class WebhooksTransport(abc.ABC): - """Abstract transport class for Webhooks.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/dialogflow', - ) - - DEFAULT_HOST: str = 'dialogflow.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.list_webhooks: gapic_v1.method.wrap_method( - self.list_webhooks, - default_timeout=None, - client_info=client_info, - ), - self.get_webhook: gapic_v1.method.wrap_method( - self.get_webhook, - default_timeout=None, - client_info=client_info, - ), - self.create_webhook: gapic_v1.method.wrap_method( - self.create_webhook, - default_timeout=None, - client_info=client_info, - ), - self.update_webhook: gapic_v1.method.wrap_method( - self.update_webhook, - default_timeout=None, - client_info=client_info, - ), - self.delete_webhook: gapic_v1.method.wrap_method( - self.delete_webhook, - 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 list_webhooks(self) -> Callable[ - [webhook.ListWebhooksRequest], - Union[ - webhook.ListWebhooksResponse, - Awaitable[webhook.ListWebhooksResponse] - ]]: - raise NotImplementedError() - - @property - def get_webhook(self) -> Callable[ - [webhook.GetWebhookRequest], - Union[ - webhook.Webhook, - Awaitable[webhook.Webhook] - ]]: - raise NotImplementedError() - - @property - def create_webhook(self) -> Callable[ - [gcdc_webhook.CreateWebhookRequest], - Union[ - gcdc_webhook.Webhook, - Awaitable[gcdc_webhook.Webhook] - ]]: - raise NotImplementedError() - - @property - def update_webhook(self) -> Callable[ - [gcdc_webhook.UpdateWebhookRequest], - Union[ - gcdc_webhook.Webhook, - Awaitable[gcdc_webhook.Webhook] - ]]: - raise NotImplementedError() - - @property - def delete_webhook(self) -> Callable[ - [webhook.DeleteWebhookRequest], - 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 get_location(self, - ) -> Callable[ - [locations_pb2.GetLocationRequest], - Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], - ]: - raise NotImplementedError() - - @property - def list_locations(self, - ) -> Callable[ - [locations_pb2.ListLocationsRequest], - Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'WebhooksTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc.py deleted file mode 100644 index 512bd9d7..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc.py +++ /dev/null @@ -1,464 +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 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.dialogflowcx_v3.types import webhook -from google.cloud.dialogflowcx_v3.types import webhook as gcdc_webhook -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from .base import WebhooksTransport, DEFAULT_CLIENT_INFO - - -class WebhooksGrpcTransport(WebhooksTransport): - """gRPC backend transport for Webhooks. - - Service for managing - [Webhooks][google.cloud.dialogflow.cx.v3.Webhook]. - - 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 = 'dialogflow.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] = {} - - 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 = 'dialogflow.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 list_webhooks(self) -> Callable[ - [webhook.ListWebhooksRequest], - webhook.ListWebhooksResponse]: - r"""Return a callable for the list webhooks method over gRPC. - - Returns the list of all webhooks in the specified - agent. - - Returns: - Callable[[~.ListWebhooksRequest], - ~.ListWebhooksResponse]: - 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_webhooks' not in self._stubs: - self._stubs['list_webhooks'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Webhooks/ListWebhooks', - request_serializer=webhook.ListWebhooksRequest.serialize, - response_deserializer=webhook.ListWebhooksResponse.deserialize, - ) - return self._stubs['list_webhooks'] - - @property - def get_webhook(self) -> Callable[ - [webhook.GetWebhookRequest], - webhook.Webhook]: - r"""Return a callable for the get webhook method over gRPC. - - Retrieves the specified webhook. - - Returns: - Callable[[~.GetWebhookRequest], - ~.Webhook]: - 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_webhook' not in self._stubs: - self._stubs['get_webhook'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Webhooks/GetWebhook', - request_serializer=webhook.GetWebhookRequest.serialize, - response_deserializer=webhook.Webhook.deserialize, - ) - return self._stubs['get_webhook'] - - @property - def create_webhook(self) -> Callable[ - [gcdc_webhook.CreateWebhookRequest], - gcdc_webhook.Webhook]: - r"""Return a callable for the create webhook method over gRPC. - - Creates a webhook in the specified agent. - - Returns: - Callable[[~.CreateWebhookRequest], - ~.Webhook]: - 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_webhook' not in self._stubs: - self._stubs['create_webhook'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Webhooks/CreateWebhook', - request_serializer=gcdc_webhook.CreateWebhookRequest.serialize, - response_deserializer=gcdc_webhook.Webhook.deserialize, - ) - return self._stubs['create_webhook'] - - @property - def update_webhook(self) -> Callable[ - [gcdc_webhook.UpdateWebhookRequest], - gcdc_webhook.Webhook]: - r"""Return a callable for the update webhook method over gRPC. - - Updates the specified webhook. - - Returns: - Callable[[~.UpdateWebhookRequest], - ~.Webhook]: - 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_webhook' not in self._stubs: - self._stubs['update_webhook'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Webhooks/UpdateWebhook', - request_serializer=gcdc_webhook.UpdateWebhookRequest.serialize, - response_deserializer=gcdc_webhook.Webhook.deserialize, - ) - return self._stubs['update_webhook'] - - @property - def delete_webhook(self) -> Callable[ - [webhook.DeleteWebhookRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete webhook method over gRPC. - - Deletes the specified webhook. - - Returns: - Callable[[~.DeleteWebhookRequest], - ~.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_webhook' not in self._stubs: - self._stubs['delete_webhook'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Webhooks/DeleteWebhook', - request_serializer=webhook.DeleteWebhookRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_webhook'] - - 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 list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'WebhooksGrpcTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc_asyncio.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc_asyncio.py deleted file mode 100644 index f05a59e2..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc_asyncio.py +++ /dev/null @@ -1,463 +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.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.dialogflowcx_v3.types import webhook -from google.cloud.dialogflowcx_v3.types import webhook as gcdc_webhook -from google.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -from google.protobuf import empty_pb2 # type: ignore -from .base import WebhooksTransport, DEFAULT_CLIENT_INFO -from .grpc import WebhooksGrpcTransport - - -class WebhooksGrpcAsyncIOTransport(WebhooksTransport): - """gRPC AsyncIO backend transport for Webhooks. - - Service for managing - [Webhooks][google.cloud.dialogflow.cx.v3.Webhook]. - - 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 = 'dialogflow.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 = 'dialogflow.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] = {} - - 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 list_webhooks(self) -> Callable[ - [webhook.ListWebhooksRequest], - Awaitable[webhook.ListWebhooksResponse]]: - r"""Return a callable for the list webhooks method over gRPC. - - Returns the list of all webhooks in the specified - agent. - - Returns: - Callable[[~.ListWebhooksRequest], - Awaitable[~.ListWebhooksResponse]]: - 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_webhooks' not in self._stubs: - self._stubs['list_webhooks'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Webhooks/ListWebhooks', - request_serializer=webhook.ListWebhooksRequest.serialize, - response_deserializer=webhook.ListWebhooksResponse.deserialize, - ) - return self._stubs['list_webhooks'] - - @property - def get_webhook(self) -> Callable[ - [webhook.GetWebhookRequest], - Awaitable[webhook.Webhook]]: - r"""Return a callable for the get webhook method over gRPC. - - Retrieves the specified webhook. - - Returns: - Callable[[~.GetWebhookRequest], - Awaitable[~.Webhook]]: - 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_webhook' not in self._stubs: - self._stubs['get_webhook'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Webhooks/GetWebhook', - request_serializer=webhook.GetWebhookRequest.serialize, - response_deserializer=webhook.Webhook.deserialize, - ) - return self._stubs['get_webhook'] - - @property - def create_webhook(self) -> Callable[ - [gcdc_webhook.CreateWebhookRequest], - Awaitable[gcdc_webhook.Webhook]]: - r"""Return a callable for the create webhook method over gRPC. - - Creates a webhook in the specified agent. - - Returns: - Callable[[~.CreateWebhookRequest], - Awaitable[~.Webhook]]: - 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_webhook' not in self._stubs: - self._stubs['create_webhook'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Webhooks/CreateWebhook', - request_serializer=gcdc_webhook.CreateWebhookRequest.serialize, - response_deserializer=gcdc_webhook.Webhook.deserialize, - ) - return self._stubs['create_webhook'] - - @property - def update_webhook(self) -> Callable[ - [gcdc_webhook.UpdateWebhookRequest], - Awaitable[gcdc_webhook.Webhook]]: - r"""Return a callable for the update webhook method over gRPC. - - Updates the specified webhook. - - Returns: - Callable[[~.UpdateWebhookRequest], - Awaitable[~.Webhook]]: - 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_webhook' not in self._stubs: - self._stubs['update_webhook'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Webhooks/UpdateWebhook', - request_serializer=gcdc_webhook.UpdateWebhookRequest.serialize, - response_deserializer=gcdc_webhook.Webhook.deserialize, - ) - return self._stubs['update_webhook'] - - @property - def delete_webhook(self) -> Callable[ - [webhook.DeleteWebhookRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete webhook method over gRPC. - - Deletes the specified webhook. - - Returns: - Callable[[~.DeleteWebhookRequest], - 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_webhook' not in self._stubs: - self._stubs['delete_webhook'] = self.grpc_channel.unary_unary( - '/google.cloud.dialogflow.cx.v3.Webhooks/DeleteWebhook', - request_serializer=webhook.DeleteWebhookRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_webhook'] - - 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"] - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - -__all__ = ( - 'WebhooksGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/transports/rest.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/transports/rest.py deleted file mode 100644 index c7610a74..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/services/webhooks/transports/rest.py +++ /dev/null @@ -1,1187 +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.cloud.location import locations_pb2 # type: ignore -from google.longrunning import operations_pb2 -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.dialogflowcx_v3.types import webhook -from google.cloud.dialogflowcx_v3.types import webhook as gcdc_webhook -from google.protobuf import empty_pb2 # type: ignore - -from .base import WebhooksTransport, 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 WebhooksRestInterceptor: - """Interceptor for Webhooks. - - 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 WebhooksRestTransport. - - .. code-block:: python - class MyCustomWebhooksInterceptor(WebhooksRestInterceptor): - def pre_create_webhook(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_webhook(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_webhook(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_get_webhook(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_webhook(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_webhooks(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_webhooks(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_webhook(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_webhook(self, response): - logging.log(f"Received response: {response}") - return response - - transport = WebhooksRestTransport(interceptor=MyCustomWebhooksInterceptor()) - client = WebhooksClient(transport=transport) - - - """ - def pre_create_webhook(self, request: gcdc_webhook.CreateWebhookRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_webhook.CreateWebhookRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_webhook - - Override in a subclass to manipulate the request or metadata - before they are sent to the Webhooks server. - """ - return request, metadata - - def post_create_webhook(self, response: gcdc_webhook.Webhook) -> gcdc_webhook.Webhook: - """Post-rpc interceptor for create_webhook - - Override in a subclass to manipulate the response - after it is returned by the Webhooks server but before - it is returned to user code. - """ - return response - def pre_delete_webhook(self, request: webhook.DeleteWebhookRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[webhook.DeleteWebhookRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_webhook - - Override in a subclass to manipulate the request or metadata - before they are sent to the Webhooks server. - """ - return request, metadata - - def pre_get_webhook(self, request: webhook.GetWebhookRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[webhook.GetWebhookRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_webhook - - Override in a subclass to manipulate the request or metadata - before they are sent to the Webhooks server. - """ - return request, metadata - - def post_get_webhook(self, response: webhook.Webhook) -> webhook.Webhook: - """Post-rpc interceptor for get_webhook - - Override in a subclass to manipulate the response - after it is returned by the Webhooks server but before - it is returned to user code. - """ - return response - def pre_list_webhooks(self, request: webhook.ListWebhooksRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[webhook.ListWebhooksRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_webhooks - - Override in a subclass to manipulate the request or metadata - before they are sent to the Webhooks server. - """ - return request, metadata - - def post_list_webhooks(self, response: webhook.ListWebhooksResponse) -> webhook.ListWebhooksResponse: - """Post-rpc interceptor for list_webhooks - - Override in a subclass to manipulate the response - after it is returned by the Webhooks server but before - it is returned to user code. - """ - return response - def pre_update_webhook(self, request: gcdc_webhook.UpdateWebhookRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gcdc_webhook.UpdateWebhookRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_webhook - - Override in a subclass to manipulate the request or metadata - before they are sent to the Webhooks server. - """ - return request, metadata - - def post_update_webhook(self, response: gcdc_webhook.Webhook) -> gcdc_webhook.Webhook: - """Post-rpc interceptor for update_webhook - - Override in a subclass to manipulate the response - after it is returned by the Webhooks server but before - it is returned to user code. - """ - return response - - def pre_get_location( - self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_location - - Override in a subclass to manipulate the request or metadata - before they are sent to the Webhooks server. - """ - return request, metadata - - def post_get_location( - self, response: locations_pb2.Location - ) -> locations_pb2.Location: - """Post-rpc interceptor for get_location - - Override in a subclass to manipulate the response - after it is returned by the Webhooks server but before - it is returned to user code. - """ - return response - def pre_list_locations( - self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_locations - - Override in a subclass to manipulate the request or metadata - before they are sent to the Webhooks server. - """ - return request, metadata - - def post_list_locations( - self, response: locations_pb2.ListLocationsResponse - ) -> locations_pb2.ListLocationsResponse: - """Post-rpc interceptor for list_locations - - Override in a subclass to manipulate the response - after it is returned by the Webhooks 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 Webhooks 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 Webhooks 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 Webhooks 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 Webhooks 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 Webhooks 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 Webhooks server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class WebhooksRestStub: - _session: AuthorizedSession - _host: str - _interceptor: WebhooksRestInterceptor - - -class WebhooksRestTransport(WebhooksTransport): - """REST backend transport for Webhooks. - - Service for managing - [Webhooks][google.cloud.dialogflow.cx.v3.Webhook]. - - 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 = 'dialogflow.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[WebhooksRestInterceptor] = 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) - if client_cert_source_for_mtls: - self._session.configure_mtls_channel(client_cert_source_for_mtls) - self._interceptor = interceptor or WebhooksRestInterceptor() - self._prep_wrapped_messages(client_info) - - class _CreateWebhook(WebhooksRestStub): - def __hash__(self): - return hash("CreateWebhook") - - __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: gcdc_webhook.CreateWebhookRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_webhook.Webhook: - r"""Call the create webhook method over HTTP. - - Args: - request (~.gcdc_webhook.CreateWebhookRequest): - The request object. The request message for - [Webhooks.CreateWebhook][google.cloud.dialogflow.cx.v3.Webhooks.CreateWebhook]. - 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: - ~.gcdc_webhook.Webhook: - Webhooks host the developer's - business logic. During a session, - webhooks allow the developer to use the - data extracted by Dialogflow's natural - language processing to generate dynamic - responses, validate collected data, or - trigger actions on the backend. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*}/webhooks', - 'body': 'webhook', - }, - ] - request, metadata = self._interceptor.pre_create_webhook(request, metadata) - pb_request = gcdc_webhook.CreateWebhookRequest.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 = gcdc_webhook.Webhook() - pb_resp = gcdc_webhook.Webhook.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_webhook(resp) - return resp - - class _DeleteWebhook(WebhooksRestStub): - def __hash__(self): - return hash("DeleteWebhook") - - __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: webhook.DeleteWebhookRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete webhook method over HTTP. - - Args: - request (~.webhook.DeleteWebhookRequest): - The request object. The request message for - [Webhooks.DeleteWebhook][google.cloud.dialogflow.cx.v3.Webhooks.DeleteWebhook]. - 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': '/v3/{name=projects/*/locations/*/agents/*/webhooks/*}', - }, - ] - request, metadata = self._interceptor.pre_delete_webhook(request, metadata) - pb_request = webhook.DeleteWebhookRequest.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 _GetWebhook(WebhooksRestStub): - def __hash__(self): - return hash("GetWebhook") - - __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: webhook.GetWebhookRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> webhook.Webhook: - r"""Call the get webhook method over HTTP. - - Args: - request (~.webhook.GetWebhookRequest): - The request object. The request message for - [Webhooks.GetWebhook][google.cloud.dialogflow.cx.v3.Webhooks.GetWebhook]. - 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: - ~.webhook.Webhook: - Webhooks host the developer's - business logic. During a session, - webhooks allow the developer to use the - data extracted by Dialogflow's natural - language processing to generate dynamic - responses, validate collected data, or - trigger actions on the backend. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*/agents/*/webhooks/*}', - }, - ] - request, metadata = self._interceptor.pre_get_webhook(request, metadata) - pb_request = webhook.GetWebhookRequest.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 = webhook.Webhook() - pb_resp = webhook.Webhook.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_webhook(resp) - return resp - - class _ListWebhooks(WebhooksRestStub): - def __hash__(self): - return hash("ListWebhooks") - - __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: webhook.ListWebhooksRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> webhook.ListWebhooksResponse: - r"""Call the list webhooks method over HTTP. - - Args: - request (~.webhook.ListWebhooksRequest): - The request object. The request message for - [Webhooks.ListWebhooks][google.cloud.dialogflow.cx.v3.Webhooks.ListWebhooks]. - 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: - ~.webhook.ListWebhooksResponse: - The response message for - [Webhooks.ListWebhooks][google.cloud.dialogflow.cx.v3.Webhooks.ListWebhooks]. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{parent=projects/*/locations/*/agents/*}/webhooks', - }, - ] - request, metadata = self._interceptor.pre_list_webhooks(request, metadata) - pb_request = webhook.ListWebhooksRequest.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 = webhook.ListWebhooksResponse() - pb_resp = webhook.ListWebhooksResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_webhooks(resp) - return resp - - class _UpdateWebhook(WebhooksRestStub): - def __hash__(self): - return hash("UpdateWebhook") - - __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: gcdc_webhook.UpdateWebhookRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gcdc_webhook.Webhook: - r"""Call the update webhook method over HTTP. - - Args: - request (~.gcdc_webhook.UpdateWebhookRequest): - The request object. The request message for - [Webhooks.UpdateWebhook][google.cloud.dialogflow.cx.v3.Webhooks.UpdateWebhook]. - 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: - ~.gcdc_webhook.Webhook: - Webhooks host the developer's - business logic. During a session, - webhooks allow the developer to use the - data extracted by Dialogflow's natural - language processing to generate dynamic - responses, validate collected data, or - trigger actions on the backend. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v3/{webhook.name=projects/*/locations/*/agents/*/webhooks/*}', - 'body': 'webhook', - }, - ] - request, metadata = self._interceptor.pre_update_webhook(request, metadata) - pb_request = gcdc_webhook.UpdateWebhookRequest.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 = gcdc_webhook.Webhook() - pb_resp = gcdc_webhook.Webhook.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_webhook(resp) - return resp - - @property - def create_webhook(self) -> Callable[ - [gcdc_webhook.CreateWebhookRequest], - gcdc_webhook.Webhook]: - # 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._CreateWebhook(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_webhook(self) -> Callable[ - [webhook.DeleteWebhookRequest], - 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._DeleteWebhook(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_webhook(self) -> Callable[ - [webhook.GetWebhookRequest], - webhook.Webhook]: - # 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._GetWebhook(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_webhooks(self) -> Callable[ - [webhook.ListWebhooksRequest], - webhook.ListWebhooksResponse]: - # 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._ListWebhooks(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_webhook(self) -> Callable[ - [gcdc_webhook.UpdateWebhookRequest], - gcdc_webhook.Webhook]: - # 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._UpdateWebhook(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_location(self): - return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore - - class _GetLocation(WebhooksRestStub): - def __call__(self, - request: locations_pb2.GetLocationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.Location: - - r"""Call the get location method over HTTP. - - Args: - request (locations_pb2.GetLocationRequest): - The request object for GetLocation 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: - locations_pb2.Location: Response from GetLocation method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*/locations/*}', - }, - ] - - request, metadata = self._interceptor.pre_get_location(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 = locations_pb2.Location() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_get_location(resp) - return resp - - @property - def list_locations(self): - return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore - - class _ListLocations(WebhooksRestStub): - def __call__(self, - request: locations_pb2.ListLocationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.ListLocationsResponse: - - r"""Call the list locations method over HTTP. - - Args: - request (locations_pb2.ListLocationsRequest): - The request object for ListLocations 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: - locations_pb2.ListLocationsResponse: Response from ListLocations method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v3/{name=projects/*}/locations', - }, - ] - - request, metadata = self._interceptor.pre_list_locations(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 = locations_pb2.ListLocationsResponse() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_list_locations(resp) - return resp - - @property - def cancel_operation(self): - return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore - - class _CancelOperation(WebhooksRestStub): - 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': '/v3/{name=projects/*/operations/*}:cancel', - }, -{ - 'method': 'post', - 'uri': '/v3/{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(WebhooksRestStub): - 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': '/v3/{name=projects/*/operations/*}', - }, -{ - 'method': 'get', - 'uri': '/v3/{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(WebhooksRestStub): - 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': '/v3/{name=projects/*}/operations', - }, -{ - 'method': 'get', - 'uri': '/v3/{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__=( - 'WebhooksRestTransport', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/__init__.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/__init__.py deleted file mode 100644 index 14b1550d..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/__init__.py +++ /dev/null @@ -1,479 +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 .advanced_settings import ( - AdvancedSettings, -) -from .agent import ( - Agent, - AgentValidationResult, - CreateAgentRequest, - DeleteAgentRequest, - ExportAgentRequest, - ExportAgentResponse, - GetAgentRequest, - GetAgentValidationResultRequest, - ListAgentsRequest, - ListAgentsResponse, - RestoreAgentRequest, - SpeechToTextSettings, - UpdateAgentRequest, - ValidateAgentRequest, -) -from .audio_config import ( - InputAudioConfig, - OutputAudioConfig, - SpeechWordInfo, - SynthesizeSpeechConfig, - TextToSpeechSettings, - VoiceSelectionParams, - AudioEncoding, - OutputAudioEncoding, - SpeechModelVariant, - SsmlVoiceGender, -) -from .changelog import ( - Changelog, - GetChangelogRequest, - ListChangelogsRequest, - ListChangelogsResponse, -) -from .deployment import ( - Deployment, - GetDeploymentRequest, - ListDeploymentsRequest, - ListDeploymentsResponse, -) -from .entity_type import ( - CreateEntityTypeRequest, - DeleteEntityTypeRequest, - EntityType, - GetEntityTypeRequest, - ListEntityTypesRequest, - ListEntityTypesResponse, - UpdateEntityTypeRequest, -) -from .environment import ( - ContinuousTestResult, - CreateEnvironmentRequest, - DeleteEnvironmentRequest, - DeployFlowMetadata, - DeployFlowRequest, - DeployFlowResponse, - Environment, - GetEnvironmentRequest, - ListContinuousTestResultsRequest, - ListContinuousTestResultsResponse, - ListEnvironmentsRequest, - ListEnvironmentsResponse, - LookupEnvironmentHistoryRequest, - LookupEnvironmentHistoryResponse, - RunContinuousTestMetadata, - RunContinuousTestRequest, - RunContinuousTestResponse, - UpdateEnvironmentRequest, -) -from .experiment import ( - CreateExperimentRequest, - DeleteExperimentRequest, - Experiment, - GetExperimentRequest, - ListExperimentsRequest, - ListExperimentsResponse, - RolloutConfig, - RolloutState, - StartExperimentRequest, - StopExperimentRequest, - UpdateExperimentRequest, - VariantsHistory, - VersionVariants, -) -from .flow import ( - CreateFlowRequest, - DeleteFlowRequest, - ExportFlowRequest, - ExportFlowResponse, - Flow, - FlowImportStrategy, - FlowValidationResult, - GetFlowRequest, - GetFlowValidationResultRequest, - ImportFlowRequest, - ImportFlowResponse, - ListFlowsRequest, - ListFlowsResponse, - NluSettings, - TrainFlowRequest, - UpdateFlowRequest, - ValidateFlowRequest, -) -from .fulfillment import ( - Fulfillment, -) -from .gcs import ( - GcsDestination, -) -from .intent import ( - CreateIntentRequest, - DeleteIntentRequest, - GetIntentRequest, - Intent, - ListIntentsRequest, - ListIntentsResponse, - UpdateIntentRequest, - IntentView, -) -from .page import ( - CreatePageRequest, - DeletePageRequest, - EventHandler, - Form, - GetPageRequest, - ListPagesRequest, - ListPagesResponse, - Page, - TransitionRoute, - UpdatePageRequest, -) -from .response_message import ( - ResponseMessage, -) -from .security_settings import ( - CreateSecuritySettingsRequest, - DeleteSecuritySettingsRequest, - GetSecuritySettingsRequest, - ListSecuritySettingsRequest, - ListSecuritySettingsResponse, - SecuritySettings, - UpdateSecuritySettingsRequest, -) -from .session import ( - AudioInput, - CloudConversationDebuggingInfo, - DetectIntentRequest, - DetectIntentResponse, - DtmfInput, - EventInput, - FulfillIntentRequest, - FulfillIntentResponse, - IntentInput, - Match, - MatchIntentRequest, - MatchIntentResponse, - QueryInput, - QueryParameters, - QueryResult, - SentimentAnalysisResult, - StreamingDetectIntentRequest, - StreamingDetectIntentResponse, - StreamingRecognitionResult, - TextInput, -) -from .session_entity_type import ( - CreateSessionEntityTypeRequest, - DeleteSessionEntityTypeRequest, - GetSessionEntityTypeRequest, - ListSessionEntityTypesRequest, - ListSessionEntityTypesResponse, - SessionEntityType, - UpdateSessionEntityTypeRequest, -) -from .test_case import ( - BatchDeleteTestCasesRequest, - BatchRunTestCasesMetadata, - BatchRunTestCasesRequest, - BatchRunTestCasesResponse, - CalculateCoverageRequest, - CalculateCoverageResponse, - ConversationTurn, - CreateTestCaseRequest, - ExportTestCasesMetadata, - ExportTestCasesRequest, - ExportTestCasesResponse, - GetTestCaseRequest, - GetTestCaseResultRequest, - ImportTestCasesMetadata, - ImportTestCasesRequest, - ImportTestCasesResponse, - IntentCoverage, - ListTestCaseResultsRequest, - ListTestCaseResultsResponse, - ListTestCasesRequest, - ListTestCasesResponse, - RunTestCaseMetadata, - RunTestCaseRequest, - RunTestCaseResponse, - TestCase, - TestCaseError, - TestCaseResult, - TestConfig, - TestError, - TestRunDifference, - TransitionCoverage, - TransitionRouteGroupCoverage, - UpdateTestCaseRequest, - TestResult, -) -from .transition_route_group import ( - CreateTransitionRouteGroupRequest, - DeleteTransitionRouteGroupRequest, - GetTransitionRouteGroupRequest, - ListTransitionRouteGroupsRequest, - ListTransitionRouteGroupsResponse, - TransitionRouteGroup, - UpdateTransitionRouteGroupRequest, -) -from .validation_message import ( - ResourceName, - ValidationMessage, -) -from .version import ( - CompareVersionsRequest, - CompareVersionsResponse, - CreateVersionOperationMetadata, - CreateVersionRequest, - DeleteVersionRequest, - GetVersionRequest, - ListVersionsRequest, - ListVersionsResponse, - LoadVersionRequest, - UpdateVersionRequest, - Version, -) -from .webhook import ( - CreateWebhookRequest, - DeleteWebhookRequest, - GetWebhookRequest, - ListWebhooksRequest, - ListWebhooksResponse, - PageInfo, - SessionInfo, - UpdateWebhookRequest, - Webhook, - WebhookRequest, - WebhookResponse, -) - -__all__ = ( - 'AdvancedSettings', - 'Agent', - 'AgentValidationResult', - 'CreateAgentRequest', - 'DeleteAgentRequest', - 'ExportAgentRequest', - 'ExportAgentResponse', - 'GetAgentRequest', - 'GetAgentValidationResultRequest', - 'ListAgentsRequest', - 'ListAgentsResponse', - 'RestoreAgentRequest', - 'SpeechToTextSettings', - 'UpdateAgentRequest', - 'ValidateAgentRequest', - 'InputAudioConfig', - 'OutputAudioConfig', - 'SpeechWordInfo', - 'SynthesizeSpeechConfig', - 'TextToSpeechSettings', - 'VoiceSelectionParams', - 'AudioEncoding', - 'OutputAudioEncoding', - 'SpeechModelVariant', - 'SsmlVoiceGender', - 'Changelog', - 'GetChangelogRequest', - 'ListChangelogsRequest', - 'ListChangelogsResponse', - 'Deployment', - 'GetDeploymentRequest', - 'ListDeploymentsRequest', - 'ListDeploymentsResponse', - 'CreateEntityTypeRequest', - 'DeleteEntityTypeRequest', - 'EntityType', - 'GetEntityTypeRequest', - 'ListEntityTypesRequest', - 'ListEntityTypesResponse', - 'UpdateEntityTypeRequest', - 'ContinuousTestResult', - 'CreateEnvironmentRequest', - 'DeleteEnvironmentRequest', - 'DeployFlowMetadata', - 'DeployFlowRequest', - 'DeployFlowResponse', - 'Environment', - 'GetEnvironmentRequest', - 'ListContinuousTestResultsRequest', - 'ListContinuousTestResultsResponse', - 'ListEnvironmentsRequest', - 'ListEnvironmentsResponse', - 'LookupEnvironmentHistoryRequest', - 'LookupEnvironmentHistoryResponse', - 'RunContinuousTestMetadata', - 'RunContinuousTestRequest', - 'RunContinuousTestResponse', - 'UpdateEnvironmentRequest', - 'CreateExperimentRequest', - 'DeleteExperimentRequest', - 'Experiment', - 'GetExperimentRequest', - 'ListExperimentsRequest', - 'ListExperimentsResponse', - 'RolloutConfig', - 'RolloutState', - 'StartExperimentRequest', - 'StopExperimentRequest', - 'UpdateExperimentRequest', - 'VariantsHistory', - 'VersionVariants', - 'CreateFlowRequest', - 'DeleteFlowRequest', - 'ExportFlowRequest', - 'ExportFlowResponse', - 'Flow', - 'FlowImportStrategy', - 'FlowValidationResult', - 'GetFlowRequest', - 'GetFlowValidationResultRequest', - 'ImportFlowRequest', - 'ImportFlowResponse', - 'ListFlowsRequest', - 'ListFlowsResponse', - 'NluSettings', - 'TrainFlowRequest', - 'UpdateFlowRequest', - 'ValidateFlowRequest', - 'Fulfillment', - 'GcsDestination', - 'ImportStrategy', - 'CreateIntentRequest', - 'DeleteIntentRequest', - 'GetIntentRequest', - 'Intent', - 'ListIntentsRequest', - 'ListIntentsResponse', - 'UpdateIntentRequest', - 'IntentView', - 'CreatePageRequest', - 'DeletePageRequest', - 'EventHandler', - 'Form', - 'GetPageRequest', - 'ListPagesRequest', - 'ListPagesResponse', - 'Page', - 'TransitionRoute', - 'UpdatePageRequest', - 'ResponseMessage', - 'CreateSecuritySettingsRequest', - 'DeleteSecuritySettingsRequest', - 'GetSecuritySettingsRequest', - 'ListSecuritySettingsRequest', - 'ListSecuritySettingsResponse', - 'SecuritySettings', - 'UpdateSecuritySettingsRequest', - 'AudioInput', - 'CloudConversationDebuggingInfo', - 'DetectIntentRequest', - 'DetectIntentResponse', - 'DtmfInput', - 'EventInput', - 'FulfillIntentRequest', - 'FulfillIntentResponse', - 'IntentInput', - 'Match', - 'MatchIntentRequest', - 'MatchIntentResponse', - 'QueryInput', - 'QueryParameters', - 'QueryResult', - 'SentimentAnalysisResult', - 'StreamingDetectIntentRequest', - 'StreamingDetectIntentResponse', - 'StreamingRecognitionResult', - 'TextInput', - 'CreateSessionEntityTypeRequest', - 'DeleteSessionEntityTypeRequest', - 'GetSessionEntityTypeRequest', - 'ListSessionEntityTypesRequest', - 'ListSessionEntityTypesResponse', - 'SessionEntityType', - 'UpdateSessionEntityTypeRequest', - 'BatchDeleteTestCasesRequest', - 'BatchRunTestCasesMetadata', - 'BatchRunTestCasesRequest', - 'BatchRunTestCasesResponse', - 'CalculateCoverageRequest', - 'CalculateCoverageResponse', - 'ConversationTurn', - 'CreateTestCaseRequest', - 'ExportTestCasesMetadata', - 'ExportTestCasesRequest', - 'ExportTestCasesResponse', - 'GetTestCaseRequest', - 'GetTestCaseResultRequest', - 'ImportTestCasesMetadata', - 'ImportTestCasesRequest', - 'ImportTestCasesResponse', - 'IntentCoverage', - 'ListTestCaseResultsRequest', - 'ListTestCaseResultsResponse', - 'ListTestCasesRequest', - 'ListTestCasesResponse', - 'RunTestCaseMetadata', - 'RunTestCaseRequest', - 'RunTestCaseResponse', - 'TestCase', - 'TestCaseError', - 'TestCaseResult', - 'TestConfig', - 'TestError', - 'TestRunDifference', - 'TransitionCoverage', - 'TransitionRouteGroupCoverage', - 'UpdateTestCaseRequest', - 'TestResult', - 'CreateTransitionRouteGroupRequest', - 'DeleteTransitionRouteGroupRequest', - 'GetTransitionRouteGroupRequest', - 'ListTransitionRouteGroupsRequest', - 'ListTransitionRouteGroupsResponse', - 'TransitionRouteGroup', - 'UpdateTransitionRouteGroupRequest', - 'ResourceName', - 'ValidationMessage', - 'CompareVersionsRequest', - 'CompareVersionsResponse', - 'CreateVersionOperationMetadata', - 'CreateVersionRequest', - 'DeleteVersionRequest', - 'GetVersionRequest', - 'ListVersionsRequest', - 'ListVersionsResponse', - 'LoadVersionRequest', - 'UpdateVersionRequest', - 'Version', - 'CreateWebhookRequest', - 'DeleteWebhookRequest', - 'GetWebhookRequest', - 'ListWebhooksRequest', - 'ListWebhooksResponse', - 'PageInfo', - 'SessionInfo', - 'UpdateWebhookRequest', - 'Webhook', - 'WebhookRequest', - 'WebhookResponse', -) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/advanced_settings.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/advanced_settings.py deleted file mode 100644 index 1d3a0064..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/advanced_settings.py +++ /dev/null @@ -1,98 +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.dialogflowcx_v3.types import gcs - - -__protobuf__ = proto.module( - package='google.cloud.dialogflow.cx.v3', - manifest={ - 'AdvancedSettings', - }, -) - - -class AdvancedSettings(proto.Message): - r"""Hierarchical advanced settings for - agent/flow/page/fulfillment/parameter. Settings exposed at lower - level overrides the settings exposed at higher level. Overriding - occurs at the sub-setting level. For example, the - playback_interruption_settings at fulfillment level only overrides - the playback_interruption_settings at the agent level, leaving other - settings at the agent level unchanged. - - DTMF settings does not override each other. DTMF settings set at - different levels define DTMF detections running in parallel. - - Hierarchy: Agent->Flow->Page->Fulfillment/Parameter. - - Attributes: - audio_export_gcs_destination (google.cloud.dialogflowcx_v3.types.GcsDestination): - If present, incoming audio is exported by - Dialogflow to the configured Google Cloud - Storage destination. Exposed at the following - levels: - - - Agent level - - Flow level - logging_settings (google.cloud.dialogflowcx_v3.types.AdvancedSettings.LoggingSettings): - Settings for logging. - Settings for Dialogflow History, Contact Center - messages, StackDriver logs, and speech logging. - Exposed at the following levels: - - - Agent level. - """ - - class LoggingSettings(proto.Message): - r"""Define behaviors on logging. - - Attributes: - enable_stackdriver_logging (bool): - If true, StackDriver logging is currently - enabled. - enable_interaction_logging (bool): - If true, DF Interaction logging is currently - enabled. - """ - - enable_stackdriver_logging: bool = proto.Field( - proto.BOOL, - number=2, - ) - enable_interaction_logging: bool = proto.Field( - proto.BOOL, - number=3, - ) - - audio_export_gcs_destination: gcs.GcsDestination = proto.Field( - proto.MESSAGE, - number=2, - message=gcs.GcsDestination, - ) - logging_settings: LoggingSettings = proto.Field( - proto.MESSAGE, - number=6, - message=LoggingSettings, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/agent.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/agent.py deleted file mode 100644 index fd9337b9..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/agent.py +++ /dev/null @@ -1,737 +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.dialogflowcx_v3.types import advanced_settings as gcdc_advanced_settings -from google.cloud.dialogflowcx_v3.types import audio_config -from google.cloud.dialogflowcx_v3.types import flow -from google.protobuf import field_mask_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.dialogflow.cx.v3', - manifest={ - 'SpeechToTextSettings', - 'Agent', - 'ListAgentsRequest', - 'ListAgentsResponse', - 'GetAgentRequest', - 'CreateAgentRequest', - 'UpdateAgentRequest', - 'DeleteAgentRequest', - 'ExportAgentRequest', - 'ExportAgentResponse', - 'RestoreAgentRequest', - 'ValidateAgentRequest', - 'GetAgentValidationResultRequest', - 'AgentValidationResult', - }, -) - - -class SpeechToTextSettings(proto.Message): - r"""Settings related to speech recognition. - - Attributes: - enable_speech_adaptation (bool): - Whether to use speech adaptation for speech - recognition. - """ - - enable_speech_adaptation: bool = proto.Field( - proto.BOOL, - number=1, - ) - - -class Agent(proto.Message): - r"""Agents are best described as Natural Language Understanding (NLU) - modules that transform user requests into actionable data. You can - include agents in your app, product, or service to determine user - intent and respond to the user in a natural way. - - After you create an agent, you can add - [Intents][google.cloud.dialogflow.cx.v3.Intent], [Entity - Types][google.cloud.dialogflow.cx.v3.EntityType], - [Flows][google.cloud.dialogflow.cx.v3.Flow], - [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment], - [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], - [TransitionRouteGroups][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - and so on to manage the conversation flows. - - Attributes: - name (str): - The unique identifier of the agent. Required for the - [Agents.UpdateAgent][google.cloud.dialogflow.cx.v3.Agents.UpdateAgent] - method. - [Agents.CreateAgent][google.cloud.dialogflow.cx.v3.Agents.CreateAgent] - populates the name automatically. Format: - ``projects//locations//agents/``. - display_name (str): - Required. The human-readable name of the - agent, unique within the location. - default_language_code (str): - Required. Immutable. The default language of the agent as a - language tag. See `Language - Support `__ - for a list of the currently supported language codes. This - field cannot be set by the - [Agents.UpdateAgent][google.cloud.dialogflow.cx.v3.Agents.UpdateAgent] - method. - supported_language_codes (MutableSequence[str]): - The list of all languages supported by the agent (except for - the ``default_language_code``). - time_zone (str): - Required. The time zone of the agent from the `time zone - database `__, e.g., - America/New_York, Europe/Paris. - description (str): - The description of the agent. The maximum - length is 500 characters. If exceeded, the - request is rejected. - avatar_uri (str): - The URI of the agent's avatar. Avatars are used throughout - the Dialogflow console and in the self-hosted `Web - Demo `__ - integration. - speech_to_text_settings (google.cloud.dialogflowcx_v3.types.SpeechToTextSettings): - Speech recognition related settings. - start_flow (str): - Immutable. Name of the start flow in this agent. A start - flow will be automatically created when the agent is - created, and can only be deleted by deleting the agent. - Format: - ``projects//locations//agents//flows/``. - security_settings (str): - Name of the - [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings] - reference for the agent. Format: - ``projects//locations//securitySettings/``. - enable_stackdriver_logging (bool): - Indicates if stackdriver logging is enabled for the agent. - Please use - [agent.advanced_settings][google.cloud.dialogflow.cx.v3.AdvancedSettings.LoggingSettings] - instead. - enable_spell_correction (bool): - Indicates if automatic spell correction is - enabled in detect intent requests. - locked (bool): - Indicates whether the agent is locked for changes. If the - agent is locked, modifications to the agent will be rejected - except for [RestoreAgent][]. - advanced_settings (google.cloud.dialogflowcx_v3.types.AdvancedSettings): - Hierarchical advanced settings for this - agent. The settings exposed at the lower level - overrides the settings exposed at the higher - level. - git_integration_settings (google.cloud.dialogflowcx_v3.types.Agent.GitIntegrationSettings): - Git integration settings for this agent. - text_to_speech_settings (google.cloud.dialogflowcx_v3.types.TextToSpeechSettings): - Settings on instructing the speech - synthesizer on how to generate the output audio - content. - """ - - class GitIntegrationSettings(proto.Message): - r"""Settings for connecting to Git repository for an agent. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - github_settings (google.cloud.dialogflowcx_v3.types.Agent.GitIntegrationSettings.GithubSettings): - GitHub settings. - - This field is a member of `oneof`_ ``git_settings``. - """ - - class GithubSettings(proto.Message): - r"""Settings of integration with GitHub. - - Attributes: - display_name (str): - The unique repository display name for the - GitHub repository. - repository_uri (str): - The GitHub repository URI related to the - agent. - tracking_branch (str): - The branch of the GitHub repository tracked - for this agent. - access_token (str): - The access token used to authenticate the - access to the GitHub repository. - branches (MutableSequence[str]): - A list of branches configured to be used from - Dialogflow. - """ - - display_name: str = proto.Field( - proto.STRING, - number=1, - ) - repository_uri: str = proto.Field( - proto.STRING, - number=2, - ) - tracking_branch: str = proto.Field( - proto.STRING, - number=3, - ) - access_token: str = proto.Field( - proto.STRING, - number=4, - ) - branches: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=5, - ) - - github_settings: 'Agent.GitIntegrationSettings.GithubSettings' = proto.Field( - proto.MESSAGE, - number=1, - oneof='git_settings', - message='Agent.GitIntegrationSettings.GithubSettings', - ) - - name: str = proto.Field( - proto.STRING, - number=1, - ) - display_name: str = proto.Field( - proto.STRING, - number=2, - ) - default_language_code: str = proto.Field( - proto.STRING, - number=3, - ) - supported_language_codes: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=4, - ) - time_zone: str = proto.Field( - proto.STRING, - number=5, - ) - description: str = proto.Field( - proto.STRING, - number=6, - ) - avatar_uri: str = proto.Field( - proto.STRING, - number=7, - ) - speech_to_text_settings: 'SpeechToTextSettings' = proto.Field( - proto.MESSAGE, - number=13, - message='SpeechToTextSettings', - ) - start_flow: str = proto.Field( - proto.STRING, - number=16, - ) - security_settings: str = proto.Field( - proto.STRING, - number=17, - ) - enable_stackdriver_logging: bool = proto.Field( - proto.BOOL, - number=18, - ) - enable_spell_correction: bool = proto.Field( - proto.BOOL, - number=20, - ) - locked: bool = proto.Field( - proto.BOOL, - number=27, - ) - advanced_settings: gcdc_advanced_settings.AdvancedSettings = proto.Field( - proto.MESSAGE, - number=22, - message=gcdc_advanced_settings.AdvancedSettings, - ) - git_integration_settings: GitIntegrationSettings = proto.Field( - proto.MESSAGE, - number=30, - message=GitIntegrationSettings, - ) - text_to_speech_settings: audio_config.TextToSpeechSettings = proto.Field( - proto.MESSAGE, - number=31, - message=audio_config.TextToSpeechSettings, - ) - - -class ListAgentsRequest(proto.Message): - r"""The request message for - [Agents.ListAgents][google.cloud.dialogflow.cx.v3.Agents.ListAgents]. - - Attributes: - parent (str): - Required. The location to list all agents for. Format: - ``projects//locations/``. - page_size (int): - The maximum number of items to return in a - single page. By default 100 and at most 1000. - page_token (str): - The next_page_token value returned from a previous list - request. - """ - - 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 ListAgentsResponse(proto.Message): - r"""The response message for - [Agents.ListAgents][google.cloud.dialogflow.cx.v3.Agents.ListAgents]. - - Attributes: - agents (MutableSequence[google.cloud.dialogflowcx_v3.types.Agent]): - The list of agents. There will be a maximum number of items - returned based on the page_size field in the request. - next_page_token (str): - Token to retrieve the next page of results, - or empty if there are no more results in the - list. - """ - - @property - def raw_page(self): - return self - - agents: MutableSequence['Agent'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Agent', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetAgentRequest(proto.Message): - r"""The request message for - [Agents.GetAgent][google.cloud.dialogflow.cx.v3.Agents.GetAgent]. - - Attributes: - name (str): - Required. The name of the agent. Format: - ``projects//locations//agents/``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateAgentRequest(proto.Message): - r"""The request message for - [Agents.CreateAgent][google.cloud.dialogflow.cx.v3.Agents.CreateAgent]. - - Attributes: - parent (str): - Required. The location to create a agent for. Format: - ``projects//locations/``. - agent (google.cloud.dialogflowcx_v3.types.Agent): - Required. The agent to create. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - agent: 'Agent' = proto.Field( - proto.MESSAGE, - number=2, - message='Agent', - ) - - -class UpdateAgentRequest(proto.Message): - r"""The request message for - [Agents.UpdateAgent][google.cloud.dialogflow.cx.v3.Agents.UpdateAgent]. - - Attributes: - agent (google.cloud.dialogflowcx_v3.types.Agent): - Required. The agent to update. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The mask to control which fields get updated. - If the mask is not present, all fields will be - updated. - """ - - agent: 'Agent' = proto.Field( - proto.MESSAGE, - number=1, - message='Agent', - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteAgentRequest(proto.Message): - r"""The request message for - [Agents.DeleteAgent][google.cloud.dialogflow.cx.v3.Agents.DeleteAgent]. - - Attributes: - name (str): - Required. The name of the agent to delete. Format: - ``projects//locations//agents/``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ExportAgentRequest(proto.Message): - r"""The request message for - [Agents.ExportAgent][google.cloud.dialogflow.cx.v3.Agents.ExportAgent]. - - Attributes: - name (str): - Required. The name of the agent to export. Format: - ``projects//locations//agents/``. - agent_uri (str): - Optional. The `Google Cloud - Storage `__ URI to - export the agent to. The format of this URI must be - ``gs:///``. If left unspecified, - the serialized agent is returned inline. - - Dialogflow performs a write operation for the Cloud Storage - object on the caller's behalf, so your request - authentication must have write permissions for the object. - For more information, see `Dialogflow access - control `__. - data_format (google.cloud.dialogflowcx_v3.types.ExportAgentRequest.DataFormat): - Optional. The data format of the exported agent. If not - specified, ``BLOB`` is assumed. - environment (str): - Optional. Environment name. If not set, draft environment is - assumed. Format: - ``projects//locations//agents//environments/``. - git_destination (google.cloud.dialogflowcx_v3.types.ExportAgentRequest.GitDestination): - Optional. The Git branch to export the agent - to. - include_bigquery_export_settings (bool): - Optional. Whether to include BigQuery Export - setting. - """ - class DataFormat(proto.Enum): - r"""Data format of the exported agent. - - Values: - DATA_FORMAT_UNSPECIFIED (0): - Unspecified format. - BLOB (1): - Agent content will be exported as raw bytes. - JSON_PACKAGE (4): - Agent content will be exported in JSON - Package format. - """ - DATA_FORMAT_UNSPECIFIED = 0 - BLOB = 1 - JSON_PACKAGE = 4 - - class GitDestination(proto.Message): - r"""Settings for exporting to a git branch. - - Attributes: - tracking_branch (str): - Tracking branch for the git push. - commit_message (str): - Commit message for the git push. - """ - - tracking_branch: str = proto.Field( - proto.STRING, - number=1, - ) - commit_message: str = proto.Field( - proto.STRING, - number=2, - ) - - name: str = proto.Field( - proto.STRING, - number=1, - ) - agent_uri: str = proto.Field( - proto.STRING, - number=2, - ) - data_format: DataFormat = proto.Field( - proto.ENUM, - number=3, - enum=DataFormat, - ) - environment: str = proto.Field( - proto.STRING, - number=5, - ) - git_destination: GitDestination = proto.Field( - proto.MESSAGE, - number=6, - message=GitDestination, - ) - include_bigquery_export_settings: bool = proto.Field( - proto.BOOL, - number=7, - ) - - -class ExportAgentResponse(proto.Message): - r"""The response message for - [Agents.ExportAgent][google.cloud.dialogflow.cx.v3.Agents.ExportAgent]. - - 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: - agent_uri (str): - The URI to a file containing the exported agent. This field - is populated if ``agent_uri`` is specified in - [ExportAgentRequest][google.cloud.dialogflow.cx.v3.ExportAgentRequest]. - - This field is a member of `oneof`_ ``agent``. - agent_content (bytes): - Uncompressed raw byte content for agent. This field is - populated if none of ``agent_uri`` and ``git_destination`` - are specified in - [ExportAgentRequest][google.cloud.dialogflow.cx.v3.ExportAgentRequest]. - - This field is a member of `oneof`_ ``agent``. - commit_sha (str): - Commit SHA of the git push. This field is populated if - ``git_destination`` is specified in - [ExportAgentRequest][google.cloud.dialogflow.cx.v3.ExportAgentRequest]. - - This field is a member of `oneof`_ ``agent``. - """ - - agent_uri: str = proto.Field( - proto.STRING, - number=1, - oneof='agent', - ) - agent_content: bytes = proto.Field( - proto.BYTES, - number=2, - oneof='agent', - ) - commit_sha: str = proto.Field( - proto.STRING, - number=3, - oneof='agent', - ) - - -class RestoreAgentRequest(proto.Message): - r"""The request message for - [Agents.RestoreAgent][google.cloud.dialogflow.cx.v3.Agents.RestoreAgent]. - - 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: - name (str): - Required. The name of the agent to restore into. Format: - ``projects//locations//agents/``. - agent_uri (str): - The `Google Cloud - Storage `__ URI to - restore agent from. The format of this URI must be - ``gs:///``. - - Dialogflow performs a read operation for the Cloud Storage - object on the caller's behalf, so your request - authentication must have read permissions for the object. - For more information, see `Dialogflow access - control `__. - - This field is a member of `oneof`_ ``agent``. - agent_content (bytes): - Uncompressed raw byte content for agent. - - This field is a member of `oneof`_ ``agent``. - git_source (google.cloud.dialogflowcx_v3.types.RestoreAgentRequest.GitSource): - Setting for restoring from a git branch - - This field is a member of `oneof`_ ``agent``. - restore_option (google.cloud.dialogflowcx_v3.types.RestoreAgentRequest.RestoreOption): - Agent restore mode. If not specified, ``KEEP`` is assumed. - """ - class RestoreOption(proto.Enum): - r"""Restore option. - - Values: - RESTORE_OPTION_UNSPECIFIED (0): - Unspecified. Treated as KEEP. - KEEP (1): - Always respect the settings from the exported - agent file. It may cause a restoration failure - if some settings (e.g. model type) are not - supported in the target agent. - FALLBACK (2): - Fallback to default settings if some settings - are not supported in the target agent. - """ - RESTORE_OPTION_UNSPECIFIED = 0 - KEEP = 1 - FALLBACK = 2 - - class GitSource(proto.Message): - r"""Settings for restoring from a git branch - - Attributes: - tracking_branch (str): - tracking branch for the git pull - """ - - tracking_branch: str = proto.Field( - proto.STRING, - number=1, - ) - - name: str = proto.Field( - proto.STRING, - number=1, - ) - agent_uri: str = proto.Field( - proto.STRING, - number=2, - oneof='agent', - ) - agent_content: bytes = proto.Field( - proto.BYTES, - number=3, - oneof='agent', - ) - git_source: GitSource = proto.Field( - proto.MESSAGE, - number=6, - oneof='agent', - message=GitSource, - ) - restore_option: RestoreOption = proto.Field( - proto.ENUM, - number=5, - enum=RestoreOption, - ) - - -class ValidateAgentRequest(proto.Message): - r"""The request message for - [Agents.ValidateAgent][google.cloud.dialogflow.cx.v3.Agents.ValidateAgent]. - - Attributes: - name (str): - Required. The agent to validate. Format: - ``projects//locations//agents/``. - language_code (str): - If not specified, the agent's default - language is used. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - language_code: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetAgentValidationResultRequest(proto.Message): - r"""The request message for - [Agents.GetAgentValidationResult][google.cloud.dialogflow.cx.v3.Agents.GetAgentValidationResult]. - - Attributes: - name (str): - Required. The agent name. Format: - ``projects//locations//agents//validationResult``. - language_code (str): - If not specified, the agent's default - language is used. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - language_code: str = proto.Field( - proto.STRING, - number=2, - ) - - -class AgentValidationResult(proto.Message): - r"""The response message for - [Agents.GetAgentValidationResult][google.cloud.dialogflow.cx.v3.Agents.GetAgentValidationResult]. - - Attributes: - name (str): - The unique identifier of the agent validation result. - Format: - ``projects//locations//agents//validationResult``. - flow_validation_results (MutableSequence[google.cloud.dialogflowcx_v3.types.FlowValidationResult]): - Contains all flow validation results. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - flow_validation_results: MutableSequence[flow.FlowValidationResult] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message=flow.FlowValidationResult, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/audio_config.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/audio_config.py deleted file mode 100644 index e0640a5d..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/audio_config.py +++ /dev/null @@ -1,518 +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 - - -__protobuf__ = proto.module( - package='google.cloud.dialogflow.cx.v3', - manifest={ - 'AudioEncoding', - 'SpeechModelVariant', - 'SsmlVoiceGender', - 'OutputAudioEncoding', - 'SpeechWordInfo', - 'InputAudioConfig', - 'VoiceSelectionParams', - 'SynthesizeSpeechConfig', - 'OutputAudioConfig', - 'TextToSpeechSettings', - }, -) - - -class AudioEncoding(proto.Enum): - r"""Audio encoding of the audio content sent in the conversational query - request. Refer to the `Cloud Speech API - documentation `__ - for more details. - - Values: - AUDIO_ENCODING_UNSPECIFIED (0): - Not specified. - AUDIO_ENCODING_LINEAR_16 (1): - Uncompressed 16-bit signed little-endian - samples (Linear PCM). - AUDIO_ENCODING_FLAC (2): - ```FLAC`` `__ - (Free Lossless Audio Codec) is the recommended encoding - because it is lossless (therefore recognition is not - compromised) and requires only about half the bandwidth of - ``LINEAR16``. ``FLAC`` stream encoding supports 16-bit and - 24-bit samples, however, not all fields in ``STREAMINFO`` - are supported. - AUDIO_ENCODING_MULAW (3): - 8-bit samples that compand 14-bit audio - samples using G.711 PCMU/mu-law. - AUDIO_ENCODING_AMR (4): - Adaptive Multi-Rate Narrowband codec. ``sample_rate_hertz`` - must be 8000. - AUDIO_ENCODING_AMR_WB (5): - Adaptive Multi-Rate Wideband codec. ``sample_rate_hertz`` - must be 16000. - AUDIO_ENCODING_OGG_OPUS (6): - Opus encoded audio frames in Ogg container - (`OggOpus `__). - ``sample_rate_hertz`` must be 16000. - AUDIO_ENCODING_SPEEX_WITH_HEADER_BYTE (7): - Although the use of lossy encodings is not recommended, if a - very low bitrate encoding is required, ``OGG_OPUS`` is - highly preferred over Speex encoding. The - `Speex `__ encoding supported by - Dialogflow API has a header byte in each block, as in MIME - type ``audio/x-speex-with-header-byte``. It is a variant of - the RTP Speex encoding defined in `RFC - 5574 `__. The stream is - a sequence of blocks, one block per RTP packet. Each block - starts with a byte containing the length of the block, in - bytes, followed by one or more frames of Speex data, padded - to an integral number of bytes (octets) as specified in RFC - 5574. In other words, each RTP header is replaced with a - single byte containing the block length. Only Speex wideband - is supported. ``sample_rate_hertz`` must be 16000. - """ - AUDIO_ENCODING_UNSPECIFIED = 0 - AUDIO_ENCODING_LINEAR_16 = 1 - AUDIO_ENCODING_FLAC = 2 - AUDIO_ENCODING_MULAW = 3 - AUDIO_ENCODING_AMR = 4 - AUDIO_ENCODING_AMR_WB = 5 - AUDIO_ENCODING_OGG_OPUS = 6 - AUDIO_ENCODING_SPEEX_WITH_HEADER_BYTE = 7 - - -class SpeechModelVariant(proto.Enum): - r"""Variant of the specified [Speech - model][google.cloud.dialogflow.cx.v3.InputAudioConfig.model] to use. - - See the `Cloud Speech - documentation `__ - for which models have different variants. For example, the - "phone_call" model has both a standard and an enhanced variant. When - you use an enhanced model, you will generally receive higher quality - results than for a standard model. - - Values: - SPEECH_MODEL_VARIANT_UNSPECIFIED (0): - No model variant specified. In this case Dialogflow defaults - to USE_BEST_AVAILABLE. - USE_BEST_AVAILABLE (1): - Use the best available variant of the [Speech - model][InputAudioConfig.model] that the caller is eligible - for. - - Please see the `Dialogflow - docs `__ - for how to make your project eligible for enhanced models. - USE_STANDARD (2): - Use standard model variant even if an enhanced model is - available. See the `Cloud Speech - documentation `__ - for details about enhanced models. - USE_ENHANCED (3): - Use an enhanced model variant: - - - If an enhanced variant does not exist for the given - [model][google.cloud.dialogflow.cx.v3.InputAudioConfig.model] - and request language, Dialogflow falls back to the - standard variant. - - The `Cloud Speech - documentation `__ - describes which models have enhanced variants. - - - If the API caller isn't eligible for enhanced models, - Dialogflow returns an error. Please see the `Dialogflow - docs `__ - for how to make your project eligible. - """ - SPEECH_MODEL_VARIANT_UNSPECIFIED = 0 - USE_BEST_AVAILABLE = 1 - USE_STANDARD = 2 - USE_ENHANCED = 3 - - -class SsmlVoiceGender(proto.Enum): - r"""Gender of the voice as described in `SSML voice - element `__. - - Values: - SSML_VOICE_GENDER_UNSPECIFIED (0): - An unspecified gender, which means that the - client doesn't care which gender the selected - voice will have. - SSML_VOICE_GENDER_MALE (1): - A male voice. - SSML_VOICE_GENDER_FEMALE (2): - A female voice. - SSML_VOICE_GENDER_NEUTRAL (3): - A gender-neutral voice. - """ - SSML_VOICE_GENDER_UNSPECIFIED = 0 - SSML_VOICE_GENDER_MALE = 1 - SSML_VOICE_GENDER_FEMALE = 2 - SSML_VOICE_GENDER_NEUTRAL = 3 - - -class OutputAudioEncoding(proto.Enum): - r"""Audio encoding of the output audio format in Text-To-Speech. - - Values: - OUTPUT_AUDIO_ENCODING_UNSPECIFIED (0): - Not specified. - OUTPUT_AUDIO_ENCODING_LINEAR_16 (1): - Uncompressed 16-bit signed little-endian - samples (Linear PCM). Audio content returned as - LINEAR16 also contains a WAV header. - OUTPUT_AUDIO_ENCODING_MP3 (2): - MP3 audio at 32kbps. - OUTPUT_AUDIO_ENCODING_MP3_64_KBPS (4): - MP3 audio at 64kbps. - OUTPUT_AUDIO_ENCODING_OGG_OPUS (3): - Opus encoded audio wrapped in an ogg - container. The result will be a file which can - be played natively on Android, and in browsers - (at least Chrome and Firefox). The quality of - the encoding is considerably higher than MP3 - while using approximately the same bitrate. - OUTPUT_AUDIO_ENCODING_MULAW (5): - 8-bit samples that compand 14-bit audio - samples using G.711 PCMU/mu-law. - """ - OUTPUT_AUDIO_ENCODING_UNSPECIFIED = 0 - OUTPUT_AUDIO_ENCODING_LINEAR_16 = 1 - OUTPUT_AUDIO_ENCODING_MP3 = 2 - OUTPUT_AUDIO_ENCODING_MP3_64_KBPS = 4 - OUTPUT_AUDIO_ENCODING_OGG_OPUS = 3 - OUTPUT_AUDIO_ENCODING_MULAW = 5 - - -class SpeechWordInfo(proto.Message): - r"""Information for a word recognized by the speech recognizer. - - Attributes: - word (str): - The word this info is for. - start_offset (google.protobuf.duration_pb2.Duration): - Time offset relative to the beginning of the - audio that corresponds to the start of the - spoken word. This is an experimental feature and - the accuracy of the time offset can vary. - end_offset (google.protobuf.duration_pb2.Duration): - Time offset relative to the beginning of the - audio that corresponds to the end of the spoken - word. This is an experimental feature and the - accuracy of the time offset can vary. - confidence (float): - The Speech confidence between 0.0 and 1.0 for - this word. A higher number indicates an - estimated greater likelihood that the recognized - word is correct. The default of 0.0 is a - sentinel value indicating that confidence was - not set. - - This field is not guaranteed to be fully stable - over time for the same audio input. Users should - also not rely on it to always be provided. - """ - - word: str = proto.Field( - proto.STRING, - number=3, - ) - 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, - ) - confidence: float = proto.Field( - proto.FLOAT, - number=4, - ) - - -class InputAudioConfig(proto.Message): - r"""Instructs the speech recognizer on how to process the audio - content. - - Attributes: - audio_encoding (google.cloud.dialogflowcx_v3.types.AudioEncoding): - Required. Audio encoding of the audio content - to process. - sample_rate_hertz (int): - Sample rate (in Hertz) of the audio content sent in the - query. Refer to `Cloud Speech API - documentation `__ - for more details. - enable_word_info (bool): - Optional. If ``true``, Dialogflow returns - [SpeechWordInfo][google.cloud.dialogflow.cx.v3.SpeechWordInfo] - in - [StreamingRecognitionResult][google.cloud.dialogflow.cx.v3.StreamingRecognitionResult] - with information about the recognized speech words, e.g. - start and end time offsets. If false or unspecified, Speech - doesn't return any word-level information. - phrase_hints (MutableSequence[str]): - Optional. A list of strings containing words and phrases - that the speech recognizer should recognize with higher - likelihood. - - See `the Cloud Speech - documentation `__ - for more details. - model (str): - Optional. Which Speech model to select for the given - request. Select the model best suited to your domain to get - best results. If a model is not explicitly specified, then - we auto-select a model based on the parameters in the - InputAudioConfig. If enhanced speech model is enabled for - the agent and an enhanced version of the specified model for - the language does not exist, then the speech is recognized - using the standard version of the specified model. Refer to - `Cloud Speech API - documentation `__ - for more details. If you specify a model, the following - models typically have the best performance: - - - phone_call (best for Agent Assist and telephony) - - latest_short (best for Dialogflow non-telephony) - - command_and_search (best for very short utterances and - commands) - model_variant (google.cloud.dialogflowcx_v3.types.SpeechModelVariant): - Optional. Which variant of the [Speech - model][google.cloud.dialogflow.cx.v3.InputAudioConfig.model] - to use. - single_utterance (bool): - Optional. If ``false`` (default), recognition does not cease - until the client closes the stream. If ``true``, the - recognizer will detect a single spoken utterance in input - audio. Recognition ceases when it detects the audio's voice - has stopped or paused. In this case, once a detected intent - is received, the client should close the stream and start a - new request with a new stream as needed. Note: This setting - is relevant only for streaming methods. - """ - - audio_encoding: 'AudioEncoding' = proto.Field( - proto.ENUM, - number=1, - enum='AudioEncoding', - ) - sample_rate_hertz: int = proto.Field( - proto.INT32, - number=2, - ) - enable_word_info: bool = proto.Field( - proto.BOOL, - number=13, - ) - phrase_hints: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=4, - ) - model: str = proto.Field( - proto.STRING, - number=7, - ) - model_variant: 'SpeechModelVariant' = proto.Field( - proto.ENUM, - number=10, - enum='SpeechModelVariant', - ) - single_utterance: bool = proto.Field( - proto.BOOL, - number=8, - ) - - -class VoiceSelectionParams(proto.Message): - r"""Description of which voice to use for speech synthesis. - - Attributes: - name (str): - Optional. The name of the voice. If not set, the service - will choose a voice based on the other parameters such as - language_code and - [ssml_gender][google.cloud.dialogflow.cx.v3.VoiceSelectionParams.ssml_gender]. - - For the list of available voices, please refer to `Supported - voices and - languages `__. - ssml_gender (google.cloud.dialogflowcx_v3.types.SsmlVoiceGender): - Optional. The preferred gender of the voice. If not set, the - service will choose a voice based on the other parameters - such as language_code and - [name][google.cloud.dialogflow.cx.v3.VoiceSelectionParams.name]. - Note that this is only a preference, not requirement. If a - voice of the appropriate gender is not available, the - synthesizer substitutes a voice with a different gender - rather than failing the request. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - ssml_gender: 'SsmlVoiceGender' = proto.Field( - proto.ENUM, - number=2, - enum='SsmlVoiceGender', - ) - - -class SynthesizeSpeechConfig(proto.Message): - r"""Configuration of how speech should be synthesized. - - Attributes: - speaking_rate (float): - Optional. Speaking rate/speed, in the range [0.25, 4.0]. 1.0 - is the normal native speed supported by the specific voice. - 2.0 is twice as fast, and 0.5 is half as fast. If - unset(0.0), defaults to the native 1.0 speed. Any other - values < 0.25 or > 4.0 will return an error. - pitch (float): - Optional. Speaking pitch, in the range [-20.0, 20.0]. 20 - means increase 20 semitones from the original pitch. -20 - means decrease 20 semitones from the original pitch. - volume_gain_db (float): - Optional. Volume gain (in dB) of the normal native volume - supported by the specific voice, in the range [-96.0, 16.0]. - If unset, or set to a value of 0.0 (dB), will play at normal - native signal amplitude. A value of -6.0 (dB) will play at - approximately half the amplitude of the normal native signal - amplitude. A value of +6.0 (dB) will play at approximately - twice the amplitude of the normal native signal amplitude. - We strongly recommend not to exceed +10 (dB) as there's - usually no effective increase in loudness for any value - greater than that. - effects_profile_id (MutableSequence[str]): - Optional. An identifier which selects 'audio - effects' profiles that are applied on (post - synthesized) text to speech. Effects are applied - on top of each other in the order they are - given. - voice (google.cloud.dialogflowcx_v3.types.VoiceSelectionParams): - Optional. The desired voice of the - synthesized audio. - """ - - speaking_rate: float = proto.Field( - proto.DOUBLE, - number=1, - ) - pitch: float = proto.Field( - proto.DOUBLE, - number=2, - ) - volume_gain_db: float = proto.Field( - proto.DOUBLE, - number=3, - ) - effects_profile_id: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=5, - ) - voice: 'VoiceSelectionParams' = proto.Field( - proto.MESSAGE, - number=4, - message='VoiceSelectionParams', - ) - - -class OutputAudioConfig(proto.Message): - r"""Instructs the speech synthesizer how to generate the output - audio content. - - Attributes: - audio_encoding (google.cloud.dialogflowcx_v3.types.OutputAudioEncoding): - Required. Audio encoding of the synthesized - audio content. - sample_rate_hertz (int): - Optional. The synthesis sample rate (in - hertz) for this audio. If not provided, then the - synthesizer will use the default sample rate - based on the audio encoding. If this is - different from the voice's natural sample rate, - then the synthesizer will honor this request by - converting to the desired sample rate (which - might result in worse audio quality). - synthesize_speech_config (google.cloud.dialogflowcx_v3.types.SynthesizeSpeechConfig): - Optional. Configuration of how speech should be synthesized. - If not specified, - [Agent.text_to_speech_settings][google.cloud.dialogflow.cx.v3.Agent.text_to_speech_settings] - is applied. - """ - - audio_encoding: 'OutputAudioEncoding' = proto.Field( - proto.ENUM, - number=1, - enum='OutputAudioEncoding', - ) - sample_rate_hertz: int = proto.Field( - proto.INT32, - number=2, - ) - synthesize_speech_config: 'SynthesizeSpeechConfig' = proto.Field( - proto.MESSAGE, - number=3, - message='SynthesizeSpeechConfig', - ) - - -class TextToSpeechSettings(proto.Message): - r"""Settings related to speech synthesizing. - - Attributes: - synthesize_speech_configs (MutableMapping[str, google.cloud.dialogflowcx_v3.types.SynthesizeSpeechConfig]): - Configuration of how speech should be synthesized, mapping - from language - (https://cloud.google.com/dialogflow/cx/docs/reference/language) - to SynthesizeSpeechConfig. - - These settings affect: - - - The `phone - gateway `__ - synthesize configuration set via - [Agent.text_to_speech_settings][google.cloud.dialogflow.cx.v3.Agent.text_to_speech_settings]. - - - How speech is synthesized when invoking - [session][google.cloud.dialogflow.cx.v3.Sessions] APIs. - [Agent.text_to_speech_settings][google.cloud.dialogflow.cx.v3.Agent.text_to_speech_settings] - only applies if - [OutputAudioConfig.synthesize_speech_config][google.cloud.dialogflow.cx.v3.OutputAudioConfig.synthesize_speech_config] - is not specified. - """ - - synthesize_speech_configs: MutableMapping[str, 'SynthesizeSpeechConfig'] = proto.MapField( - proto.STRING, - proto.MESSAGE, - number=1, - message='SynthesizeSpeechConfig', - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/changelog.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/changelog.py deleted file mode 100644 index 613e125c..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/changelog.py +++ /dev/null @@ -1,187 +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 timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.dialogflow.cx.v3', - manifest={ - 'ListChangelogsRequest', - 'ListChangelogsResponse', - 'GetChangelogRequest', - 'Changelog', - }, -) - - -class ListChangelogsRequest(proto.Message): - r"""The request message for - [Changelogs.ListChangelogs][google.cloud.dialogflow.cx.v3.Changelogs.ListChangelogs]. - - Attributes: - parent (str): - Required. The agent containing the changelogs. Format: - ``projects//locations//agents/``. - filter (str): - The filter string. Supports filter by user_email, resource, - type and create_time. Some examples: - - 1. By user email: user_email = "someone@google.com" - 2. By resource name: resource = - "projects/123/locations/global/agents/456/flows/789" - 3. By resource display name: display_name = "my agent" - 4. By action: action = "Create" - 5. By type: type = "flows" - 6. By create time. Currently predicates on ``create_time`` - and ``create_time_epoch_seconds`` are supported: - create_time_epoch_seconds > 1551790877 AND create_time <= - 2017-01-15T01:30:15.01Z - 7. Combination of above filters: resource = - "projects/123/locations/global/agents/456/flows/789" AND - user_email = "someone@google.com" AND create_time <= - 2017-01-15T01:30:15.01Z - page_size (int): - The maximum number of items to return in a - single page. By default 100 and at most 1000. - page_token (str): - The next_page_token value returned from a previous list - request. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - filter: str = proto.Field( - proto.STRING, - number=2, - ) - page_size: int = proto.Field( - proto.INT32, - number=3, - ) - page_token: str = proto.Field( - proto.STRING, - number=4, - ) - - -class ListChangelogsResponse(proto.Message): - r"""The response message for - [Changelogs.ListChangelogs][google.cloud.dialogflow.cx.v3.Changelogs.ListChangelogs]. - - Attributes: - changelogs (MutableSequence[google.cloud.dialogflowcx_v3.types.Changelog]): - The list of changelogs. There will be a maximum number of - items returned based on the page_size field in the request. - The changelogs will be ordered by timestamp. - next_page_token (str): - Token to retrieve the next page of results, - or empty if there are no more results in the - list. - """ - - @property - def raw_page(self): - return self - - changelogs: MutableSequence['Changelog'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Changelog', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetChangelogRequest(proto.Message): - r"""The request message for - [Changelogs.GetChangelog][google.cloud.dialogflow.cx.v3.Changelogs.GetChangelog]. - - Attributes: - name (str): - Required. The name of the changelog to get. Format: - ``projects//locations//agents//changelogs/``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class Changelog(proto.Message): - r"""Changelogs represents a change made to a given agent. - - Attributes: - name (str): - The unique identifier of the changelog. Format: - ``projects//locations//agents//changelogs/``. - user_email (str): - Email address of the authenticated user. - display_name (str): - The affected resource display name of the - change. - action (str): - The action of the change. - type_ (str): - The affected resource type. - resource (str): - The affected resource name of the change. - create_time (google.protobuf.timestamp_pb2.Timestamp): - The timestamp of the change. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - user_email: str = proto.Field( - proto.STRING, - number=2, - ) - display_name: str = proto.Field( - proto.STRING, - number=7, - ) - action: str = proto.Field( - proto.STRING, - number=11, - ) - type_: str = proto.Field( - proto.STRING, - number=8, - ) - resource: str = proto.Field( - proto.STRING, - number=3, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.Timestamp, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/deployment.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/deployment.py deleted file mode 100644 index d753ea13..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/deployment.py +++ /dev/null @@ -1,217 +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 timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.dialogflow.cx.v3', - manifest={ - 'Deployment', - 'ListDeploymentsRequest', - 'ListDeploymentsResponse', - 'GetDeploymentRequest', - }, -) - - -class Deployment(proto.Message): - r"""Represents a deployment in an environment. A deployment - happens when a flow version configured to be active in the - environment. You can configure running pre-deployment steps, - e.g. running validation test cases, experiment auto-rollout, - etc. - - Attributes: - name (str): - The name of the deployment. - Format: projects//locations//agents//environments//deployments/. - flow_version (str): - The name of the flow version for this - deployment. Format: projects//locations//agents//flows//versions/. - state (google.cloud.dialogflowcx_v3.types.Deployment.State): - The current state of the deployment. - result (google.cloud.dialogflowcx_v3.types.Deployment.Result): - Result of the deployment. - start_time (google.protobuf.timestamp_pb2.Timestamp): - Start time of this deployment. - end_time (google.protobuf.timestamp_pb2.Timestamp): - End time of this deployment. - """ - class State(proto.Enum): - r"""The state of the deployment. - - Values: - STATE_UNSPECIFIED (0): - State unspecified. - RUNNING (1): - The deployment is running. - SUCCEEDED (2): - The deployment succeeded. - FAILED (3): - The deployment failed. - """ - STATE_UNSPECIFIED = 0 - RUNNING = 1 - SUCCEEDED = 2 - FAILED = 3 - - class Result(proto.Message): - r"""Result of the deployment. - - Attributes: - deployment_test_results (MutableSequence[str]): - Results of test cases running before the deployment. Format: - ``projects//locations//agents//testCases//results/``. - experiment (str): - The name of the experiment triggered by this - deployment. Format: projects//locations//agents//environments//experiments/. - """ - - deployment_test_results: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=1, - ) - experiment: str = proto.Field( - proto.STRING, - number=2, - ) - - name: str = proto.Field( - proto.STRING, - number=1, - ) - flow_version: str = proto.Field( - proto.STRING, - number=2, - ) - state: State = proto.Field( - proto.ENUM, - number=3, - enum=State, - ) - result: Result = proto.Field( - proto.MESSAGE, - number=4, - message=Result, - ) - start_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=5, - message=timestamp_pb2.Timestamp, - ) - end_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - - -class ListDeploymentsRequest(proto.Message): - r"""The request message for - [Deployments.ListDeployments][google.cloud.dialogflow.cx.v3.Deployments.ListDeployments]. - - Attributes: - parent (str): - Required. The - [Environment][google.cloud.dialogflow.cx.v3.Environment] to - list all environments for. Format: - ``projects//locations//agents//environments/``. - page_size (int): - The maximum number of items to return in a - single page. By default 20 and at most 100. - page_token (str): - The next_page_token value returned from a previous list - request. - """ - - 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 ListDeploymentsResponse(proto.Message): - r"""The response message for - [Deployments.ListDeployments][google.cloud.dialogflow.cx.v3.Deployments.ListDeployments]. - - Attributes: - deployments (MutableSequence[google.cloud.dialogflowcx_v3.types.Deployment]): - The list of deployments. There will be a maximum number of - items returned based on the page_size field in the request. - The list may in some cases be empty or contain fewer entries - than page_size even if this isn't the last page. - next_page_token (str): - Token to retrieve the next page of results, - or empty if there are no more results in the - list. - """ - - @property - def raw_page(self): - return self - - deployments: MutableSequence['Deployment'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Deployment', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetDeploymentRequest(proto.Message): - r"""The request message for - [Deployments.GetDeployment][google.cloud.dialogflow.cx.v3.Deployments.GetDeployment]. - - Attributes: - name (str): - Required. The name of the - [Deployment][google.cloud.dialogflow.cx.v3.Deployment]. - Format: - ``projects//locations//agents//environments//deployments/``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/entity_type.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/entity_type.py deleted file mode 100644 index 097c8dee..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/entity_type.py +++ /dev/null @@ -1,455 +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 field_mask_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.dialogflow.cx.v3', - manifest={ - 'EntityType', - 'ListEntityTypesRequest', - 'ListEntityTypesResponse', - 'GetEntityTypeRequest', - 'CreateEntityTypeRequest', - 'UpdateEntityTypeRequest', - 'DeleteEntityTypeRequest', - }, -) - - -class EntityType(proto.Message): - r"""Entities are extracted from user input and represent parameters that - are meaningful to your application. For example, a date range, a - proper name such as a geographic location or landmark, and so on. - Entities represent actionable data for your application. - - When you define an entity, you can also include synonyms that all - map to that entity. For example, "soft drink", "soda", "pop", and so - on. - - There are three types of entities: - - - **System** - entities that are defined by the Dialogflow API for - common data types such as date, time, currency, and so on. A - system entity is represented by the ``EntityType`` type. - - - **Custom** - entities that are defined by you that represent - actionable data that is meaningful to your application. For - example, you could define a ``pizza.sauce`` entity for red or - white pizza sauce, a ``pizza.cheese`` entity for the different - types of cheese on a pizza, a ``pizza.topping`` entity for - different toppings, and so on. A custom entity is represented by - the ``EntityType`` type. - - - **User** - entities that are built for an individual user such as - favorites, preferences, playlists, and so on. A user entity is - represented by the - [SessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityType] - type. - - For more information about entity types, see the `Dialogflow - documentation `__. - - Attributes: - name (str): - The unique identifier of the entity type. Required for - [EntityTypes.UpdateEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.UpdateEntityType]. - Format: - ``projects//locations//agents//entityTypes/``. - display_name (str): - Required. The human-readable name of the - entity type, unique within the agent. - kind (google.cloud.dialogflowcx_v3.types.EntityType.Kind): - Required. Indicates the kind of entity type. - auto_expansion_mode (google.cloud.dialogflowcx_v3.types.EntityType.AutoExpansionMode): - Indicates whether the entity type can be - automatically expanded. - entities (MutableSequence[google.cloud.dialogflowcx_v3.types.EntityType.Entity]): - The collection of entity entries associated - with the entity type. - excluded_phrases (MutableSequence[google.cloud.dialogflowcx_v3.types.EntityType.ExcludedPhrase]): - Collection of exceptional words and phrases that shouldn't - be matched. For example, if you have a size entity type with - entry ``giant``\ (an adjective), you might consider adding - ``giants``\ (a noun) as an exclusion. If the kind of entity - type is ``KIND_MAP``, then the phrases specified by entities - and excluded phrases should be mutually exclusive. - enable_fuzzy_extraction (bool): - Enables fuzzy entity extraction during - classification. - redact (bool): - Indicates whether parameters of the entity - type should be redacted in log. If redaction is - enabled, page parameters and intent parameters - referring to the entity type will be replaced by - parameter name when logging. - """ - class Kind(proto.Enum): - r"""Represents kinds of entities. - - Values: - KIND_UNSPECIFIED (0): - Not specified. This value should be never - used. - KIND_MAP (1): - Map entity types allow mapping of a group of - synonyms to a canonical value. - KIND_LIST (2): - List entity types contain a set of entries - that do not map to canonical values. However, - list entity types can contain references to - other entity types (with or without aliases). - KIND_REGEXP (3): - Regexp entity types allow to specify regular - expressions in entries values. - """ - KIND_UNSPECIFIED = 0 - KIND_MAP = 1 - KIND_LIST = 2 - KIND_REGEXP = 3 - - class AutoExpansionMode(proto.Enum): - r"""Represents different entity type expansion modes. Automated - expansion allows an agent to recognize values that have not been - explicitly listed in the entity (for example, new kinds of - shopping list items). - - Values: - AUTO_EXPANSION_MODE_UNSPECIFIED (0): - Auto expansion disabled for the entity. - AUTO_EXPANSION_MODE_DEFAULT (1): - Allows an agent to recognize values that have - not been explicitly listed in the entity. - """ - AUTO_EXPANSION_MODE_UNSPECIFIED = 0 - AUTO_EXPANSION_MODE_DEFAULT = 1 - - class Entity(proto.Message): - r"""An **entity entry** for an associated entity type. - - Attributes: - value (str): - Required. The primary value associated with this entity - entry. For example, if the entity type is *vegetable*, the - value could be *scallions*. - - For ``KIND_MAP`` entity types: - - - A canonical value to be used in place of synonyms. - - For ``KIND_LIST`` entity types: - - - A string that can contain references to other entity - types (with or without aliases). - synonyms (MutableSequence[str]): - Required. A collection of value synonyms. For example, if - the entity type is *vegetable*, and ``value`` is - *scallions*, a synonym could be *green onions*. - - For ``KIND_LIST`` entity types: - - - This collection must contain exactly one synonym equal to - ``value``. - """ - - value: str = proto.Field( - proto.STRING, - number=1, - ) - synonyms: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=2, - ) - - class ExcludedPhrase(proto.Message): - r"""An excluded entity phrase that should not be matched. - - Attributes: - value (str): - Required. The word or phrase to be excluded. - """ - - value: str = proto.Field( - proto.STRING, - number=1, - ) - - name: str = proto.Field( - proto.STRING, - number=1, - ) - display_name: str = proto.Field( - proto.STRING, - number=2, - ) - kind: Kind = proto.Field( - proto.ENUM, - number=3, - enum=Kind, - ) - auto_expansion_mode: AutoExpansionMode = proto.Field( - proto.ENUM, - number=4, - enum=AutoExpansionMode, - ) - entities: MutableSequence[Entity] = proto.RepeatedField( - proto.MESSAGE, - number=5, - message=Entity, - ) - excluded_phrases: MutableSequence[ExcludedPhrase] = proto.RepeatedField( - proto.MESSAGE, - number=6, - message=ExcludedPhrase, - ) - enable_fuzzy_extraction: bool = proto.Field( - proto.BOOL, - number=7, - ) - redact: bool = proto.Field( - proto.BOOL, - number=9, - ) - - -class ListEntityTypesRequest(proto.Message): - r"""The request message for - [EntityTypes.ListEntityTypes][google.cloud.dialogflow.cx.v3.EntityTypes.ListEntityTypes]. - - Attributes: - parent (str): - Required. The agent to list all entity types for. Format: - ``projects//locations//agents/``. - language_code (str): - The language to list entity types for. The following fields - are language dependent: - - - ``EntityType.entities.value`` - - ``EntityType.entities.synonyms`` - - ``EntityType.excluded_phrases.value`` - - If not specified, the agent's default language is used. - `Many - languages `__ - are supported. Note: languages must be enabled in the agent - before they can be used. - page_size (int): - The maximum number of items to return in a - single page. By default 100 and at most 1000. - page_token (str): - The next_page_token value returned from a previous list - request. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - language_code: str = proto.Field( - proto.STRING, - number=2, - ) - page_size: int = proto.Field( - proto.INT32, - number=3, - ) - page_token: str = proto.Field( - proto.STRING, - number=4, - ) - - -class ListEntityTypesResponse(proto.Message): - r"""The response message for - [EntityTypes.ListEntityTypes][google.cloud.dialogflow.cx.v3.EntityTypes.ListEntityTypes]. - - Attributes: - entity_types (MutableSequence[google.cloud.dialogflowcx_v3.types.EntityType]): - The list of entity types. There will be a maximum number of - items returned based on the page_size field in the request. - next_page_token (str): - Token to retrieve the next page of results, - or empty if there are no more results in the - list. - """ - - @property - def raw_page(self): - return self - - entity_types: MutableSequence['EntityType'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='EntityType', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetEntityTypeRequest(proto.Message): - r"""The request message for - [EntityTypes.GetEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.GetEntityType]. - - Attributes: - name (str): - Required. The name of the entity type. Format: - ``projects//locations//agents//entityTypes/``. - language_code (str): - The language to retrieve the entity type for. The following - fields are language dependent: - - - ``EntityType.entities.value`` - - ``EntityType.entities.synonyms`` - - ``EntityType.excluded_phrases.value`` - - If not specified, the agent's default language is used. - `Many - languages `__ - are supported. Note: languages must be enabled in the agent - before they can be used. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - language_code: str = proto.Field( - proto.STRING, - number=2, - ) - - -class CreateEntityTypeRequest(proto.Message): - r"""The request message for - [EntityTypes.CreateEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.CreateEntityType]. - - Attributes: - parent (str): - Required. The agent to create a entity type for. Format: - ``projects//locations//agents/``. - entity_type (google.cloud.dialogflowcx_v3.types.EntityType): - Required. The entity type to create. - language_code (str): - The language of the following fields in ``entity_type``: - - - ``EntityType.entities.value`` - - ``EntityType.entities.synonyms`` - - ``EntityType.excluded_phrases.value`` - - If not specified, the agent's default language is used. - `Many - languages `__ - are supported. Note: languages must be enabled in the agent - before they can be used. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - entity_type: 'EntityType' = proto.Field( - proto.MESSAGE, - number=2, - message='EntityType', - ) - language_code: str = proto.Field( - proto.STRING, - number=3, - ) - - -class UpdateEntityTypeRequest(proto.Message): - r"""The request message for - [EntityTypes.UpdateEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.UpdateEntityType]. - - Attributes: - entity_type (google.cloud.dialogflowcx_v3.types.EntityType): - Required. The entity type to update. - language_code (str): - The language of the following fields in ``entity_type``: - - - ``EntityType.entities.value`` - - ``EntityType.entities.synonyms`` - - ``EntityType.excluded_phrases.value`` - - If not specified, the agent's default language is used. - `Many - languages `__ - are supported. Note: languages must be enabled in the agent - before they can be used. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The mask to control which fields get updated. - """ - - entity_type: 'EntityType' = proto.Field( - proto.MESSAGE, - number=1, - message='EntityType', - ) - language_code: str = proto.Field( - proto.STRING, - number=2, - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=3, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteEntityTypeRequest(proto.Message): - r"""The request message for - [EntityTypes.DeleteEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.DeleteEntityType]. - - Attributes: - name (str): - Required. The name of the entity type to delete. Format: - ``projects//locations//agents//entityTypes/``. - force (bool): - This field has no effect for entity type not being used. For - entity types that are used by intents or pages: - - - If ``force`` is set to false, an error will be returned - with message indicating the referencing resources. - - If ``force`` is set to true, Dialogflow will remove the - entity type, as well as any references to the entity type - (i.e. Page - [parameter][google.cloud.dialogflow.cx.v3.Form.Parameter] - of the entity type will be changed to '@sys.any' and - intent - [parameter][google.cloud.dialogflow.cx.v3.Intent.Parameter] - of the entity type will be removed). - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - force: bool = proto.Field( - proto.BOOL, - number=2, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/environment.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/environment.py deleted file mode 100644 index c8f216fa..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/environment.py +++ /dev/null @@ -1,628 +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.dialogflowcx_v3.types import test_case -from google.cloud.dialogflowcx_v3.types import webhook -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.dialogflow.cx.v3', - manifest={ - 'Environment', - 'ListEnvironmentsRequest', - 'ListEnvironmentsResponse', - 'GetEnvironmentRequest', - 'CreateEnvironmentRequest', - 'UpdateEnvironmentRequest', - 'DeleteEnvironmentRequest', - 'LookupEnvironmentHistoryRequest', - 'LookupEnvironmentHistoryResponse', - 'ContinuousTestResult', - 'RunContinuousTestRequest', - 'RunContinuousTestResponse', - 'RunContinuousTestMetadata', - 'ListContinuousTestResultsRequest', - 'ListContinuousTestResultsResponse', - 'DeployFlowRequest', - 'DeployFlowResponse', - 'DeployFlowMetadata', - }, -) - - -class Environment(proto.Message): - r"""Represents an environment for an agent. You can create - multiple versions of your agent and publish them to separate - environments. When you edit an agent, you are editing the draft - agent. At any point, you can save the draft agent as an agent - version, which is an immutable snapshot of your agent. When you - save the draft agent, it is published to the default - environment. When you create agent versions, you can publish - them to custom environments. You can create a variety of custom - environments for testing, development, production, etc. - - Attributes: - name (str): - The name of the environment. Format: - ``projects//locations//agents//environments/``. - display_name (str): - Required. The human-readable name of the - environment (unique in an agent). Limit of 64 - characters. - description (str): - The human-readable description of the - environment. The maximum length is 500 - characters. If exceeded, the request is - rejected. - version_configs (MutableSequence[google.cloud.dialogflowcx_v3.types.Environment.VersionConfig]): - A list of configurations for flow versions. You should - include version configs for all flows that are reachable - from [``Start Flow``][Agent.start_flow] in the agent. - Otherwise, an error will be returned. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. Update time of this environment. - test_cases_config (google.cloud.dialogflowcx_v3.types.Environment.TestCasesConfig): - The test cases config for continuous tests of - this environment. - webhook_config (google.cloud.dialogflowcx_v3.types.Environment.WebhookConfig): - The webhook configuration for this - environment. - """ - - class VersionConfig(proto.Message): - r"""Configuration for the version. - - Attributes: - version (str): - Required. Format: projects//locations//agents//flows//versions/. - """ - - version: str = proto.Field( - proto.STRING, - number=1, - ) - - class TestCasesConfig(proto.Message): - r"""The configuration for continuous tests. - - Attributes: - test_cases (MutableSequence[str]): - A list of test case names to run. They should be under the - same agent. Format of each test case name: - ``projects//locations/ /agents//testCases/`` - enable_continuous_run (bool): - Whether to run test cases in - [TestCasesConfig.test_cases][google.cloud.dialogflow.cx.v3.Environment.TestCasesConfig.test_cases] - periodically. Default false. If set to true, run once a day. - enable_predeployment_run (bool): - Whether to run test cases in - [TestCasesConfig.test_cases][google.cloud.dialogflow.cx.v3.Environment.TestCasesConfig.test_cases] - before deploying a flow version to the environment. Default - false. - """ - - test_cases: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=1, - ) - enable_continuous_run: bool = proto.Field( - proto.BOOL, - number=2, - ) - enable_predeployment_run: bool = proto.Field( - proto.BOOL, - number=3, - ) - - class WebhookConfig(proto.Message): - r"""Configuration for webhooks. - - Attributes: - webhook_overrides (MutableSequence[google.cloud.dialogflowcx_v3.types.Webhook]): - The list of webhooks to override for the agent environment. - The webhook must exist in the agent. You can override fields - in - [``generic_web_service``][google.cloud.dialogflow.cx.v3.Webhook.generic_web_service] - and - [``service_directory``][google.cloud.dialogflow.cx.v3.Webhook.service_directory]. - """ - - webhook_overrides: MutableSequence[webhook.Webhook] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=webhook.Webhook, - ) - - name: str = proto.Field( - proto.STRING, - number=1, - ) - display_name: str = proto.Field( - proto.STRING, - number=2, - ) - description: str = proto.Field( - proto.STRING, - number=3, - ) - version_configs: MutableSequence[VersionConfig] = proto.RepeatedField( - proto.MESSAGE, - number=6, - message=VersionConfig, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=5, - message=timestamp_pb2.Timestamp, - ) - test_cases_config: TestCasesConfig = proto.Field( - proto.MESSAGE, - number=7, - message=TestCasesConfig, - ) - webhook_config: WebhookConfig = proto.Field( - proto.MESSAGE, - number=10, - message=WebhookConfig, - ) - - -class ListEnvironmentsRequest(proto.Message): - r"""The request message for - [Environments.ListEnvironments][google.cloud.dialogflow.cx.v3.Environments.ListEnvironments]. - - Attributes: - parent (str): - Required. The [Agent][google.cloud.dialogflow.cx.v3.Agent] - to list all environments for. Format: - ``projects//locations//agents/``. - page_size (int): - The maximum number of items to return in a - single page. By default 20 and at most 100. - page_token (str): - The next_page_token value returned from a previous list - request. - """ - - 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 ListEnvironmentsResponse(proto.Message): - r"""The response message for - [Environments.ListEnvironments][google.cloud.dialogflow.cx.v3.Environments.ListEnvironments]. - - Attributes: - environments (MutableSequence[google.cloud.dialogflowcx_v3.types.Environment]): - The list of environments. There will be a maximum number of - items returned based on the page_size field in the request. - The list may in some cases be empty or contain fewer entries - than page_size even if this isn't the last page. - next_page_token (str): - Token to retrieve the next page of results, - or empty if there are no more results in the - list. - """ - - @property - def raw_page(self): - return self - - environments: MutableSequence['Environment'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Environment', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetEnvironmentRequest(proto.Message): - r"""The request message for - [Environments.GetEnvironment][google.cloud.dialogflow.cx.v3.Environments.GetEnvironment]. - - Attributes: - name (str): - Required. The name of the - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - Format: - ``projects//locations//agents//environments/``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateEnvironmentRequest(proto.Message): - r"""The request message for - [Environments.CreateEnvironment][google.cloud.dialogflow.cx.v3.Environments.CreateEnvironment]. - - Attributes: - parent (str): - Required. The [Agent][google.cloud.dialogflow.cx.v3.Agent] - to create an - [Environment][google.cloud.dialogflow.cx.v3.Environment] - for. Format: - ``projects//locations//agents/``. - environment (google.cloud.dialogflowcx_v3.types.Environment): - Required. The environment to create. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - environment: 'Environment' = proto.Field( - proto.MESSAGE, - number=2, - message='Environment', - ) - - -class UpdateEnvironmentRequest(proto.Message): - r"""The request message for - [Environments.UpdateEnvironment][google.cloud.dialogflow.cx.v3.Environments.UpdateEnvironment]. - - Attributes: - environment (google.cloud.dialogflowcx_v3.types.Environment): - Required. The environment to update. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The mask to control which fields - get updated. - """ - - environment: 'Environment' = proto.Field( - proto.MESSAGE, - number=1, - message='Environment', - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteEnvironmentRequest(proto.Message): - r"""The request message for - [Environments.DeleteEnvironment][google.cloud.dialogflow.cx.v3.Environments.DeleteEnvironment]. - - Attributes: - name (str): - Required. The name of the - [Environment][google.cloud.dialogflow.cx.v3.Environment] to - delete. Format: - ``projects//locations//agents//environments/``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class LookupEnvironmentHistoryRequest(proto.Message): - r"""The request message for - [Environments.LookupEnvironmentHistory][google.cloud.dialogflow.cx.v3.Environments.LookupEnvironmentHistory]. - - Attributes: - name (str): - Required. Resource name of the environment to look up the - history for. Format: - ``projects//locations//agents//environments/``. - page_size (int): - The maximum number of items to return in a - single page. By default 100 and at most 1000. - page_token (str): - The next_page_token value returned from a previous list - request. - """ - - name: 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 LookupEnvironmentHistoryResponse(proto.Message): - r"""The response message for - [Environments.LookupEnvironmentHistory][google.cloud.dialogflow.cx.v3.Environments.LookupEnvironmentHistory]. - - Attributes: - environments (MutableSequence[google.cloud.dialogflowcx_v3.types.Environment]): - Represents a list of snapshots for an environment. Time of - the snapshots is stored in - [``update_time``][google.cloud.dialogflow.cx.v3.Environment.update_time]. - next_page_token (str): - Token to retrieve the next page of results, - or empty if there are no more results in the - list. - """ - - @property - def raw_page(self): - return self - - environments: MutableSequence['Environment'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Environment', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class ContinuousTestResult(proto.Message): - r"""Represents a result from running a test case in an agent - environment. - - Attributes: - name (str): - The resource name for the continuous test result. Format: - ``projects//locations//agents//environments//continuousTestResults/``. - result (google.cloud.dialogflowcx_v3.types.ContinuousTestResult.AggregatedTestResult): - The result of this continuous test run, i.e. - whether all the tests in this continuous test - run pass or not. - test_case_results (MutableSequence[str]): - A list of individual test case results names - in this continuous test run. - run_time (google.protobuf.timestamp_pb2.Timestamp): - Time when the continuous testing run starts. - """ - class AggregatedTestResult(proto.Enum): - r"""The overall result for a continuous test run in an agent - environment. - - Values: - AGGREGATED_TEST_RESULT_UNSPECIFIED (0): - Not specified. Should never be used. - PASSED (1): - All the tests passed. - FAILED (2): - At least one test did not pass. - """ - AGGREGATED_TEST_RESULT_UNSPECIFIED = 0 - PASSED = 1 - FAILED = 2 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - result: AggregatedTestResult = proto.Field( - proto.ENUM, - number=2, - enum=AggregatedTestResult, - ) - test_case_results: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - run_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.Timestamp, - ) - - -class RunContinuousTestRequest(proto.Message): - r"""The request message for - [Environments.RunContinuousTest][google.cloud.dialogflow.cx.v3.Environments.RunContinuousTest]. - - Attributes: - environment (str): - Required. Format: - ``projects//locations//agents//environments/``. - """ - - environment: str = proto.Field( - proto.STRING, - number=1, - ) - - -class RunContinuousTestResponse(proto.Message): - r"""The response message for - [Environments.RunContinuousTest][google.cloud.dialogflow.cx.v3.Environments.RunContinuousTest]. - - Attributes: - continuous_test_result (google.cloud.dialogflowcx_v3.types.ContinuousTestResult): - The result for a continuous test run. - """ - - continuous_test_result: 'ContinuousTestResult' = proto.Field( - proto.MESSAGE, - number=1, - message='ContinuousTestResult', - ) - - -class RunContinuousTestMetadata(proto.Message): - r"""Metadata returned for the - [Environments.RunContinuousTest][google.cloud.dialogflow.cx.v3.Environments.RunContinuousTest] - long running operation. - - Attributes: - errors (MutableSequence[google.cloud.dialogflowcx_v3.types.TestError]): - The test errors. - """ - - errors: MutableSequence[test_case.TestError] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=test_case.TestError, - ) - - -class ListContinuousTestResultsRequest(proto.Message): - r"""The request message for - [Environments.ListContinuousTestResults][google.cloud.dialogflow.cx.v3.Environments.ListContinuousTestResults]. - - Attributes: - parent (str): - Required. The environment to list results for. Format: - ``projects//locations//agents// environments/``. - page_size (int): - The maximum number of items to return in a - single page. By default 100 and at most 1000. - page_token (str): - The next_page_token value returned from a previous list - request. - """ - - 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 ListContinuousTestResultsResponse(proto.Message): - r"""The response message for [Environments.ListTestCaseResults][]. - - Attributes: - continuous_test_results (MutableSequence[google.cloud.dialogflowcx_v3.types.ContinuousTestResult]): - The list of continuous test results. - next_page_token (str): - Token to retrieve the next page of results, - or empty if there are no more results in the - list. - """ - - @property - def raw_page(self): - return self - - continuous_test_results: MutableSequence['ContinuousTestResult'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='ContinuousTestResult', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class DeployFlowRequest(proto.Message): - r"""The request message for - [Environments.DeployFlow][google.cloud.dialogflow.cx.v3.Environments.DeployFlow]. - - Attributes: - environment (str): - Required. The environment to deploy the flow to. Format: - ``projects//locations//agents// environments/``. - flow_version (str): - Required. The flow version to deploy. Format: - ``projects//locations//agents// flows//versions/``. - """ - - environment: str = proto.Field( - proto.STRING, - number=1, - ) - flow_version: str = proto.Field( - proto.STRING, - number=2, - ) - - -class DeployFlowResponse(proto.Message): - r"""The response message for - [Environments.DeployFlow][google.cloud.dialogflow.cx.v3.Environments.DeployFlow]. - - Attributes: - environment (google.cloud.dialogflowcx_v3.types.Environment): - The updated environment where the flow is - deployed. - deployment (str): - The name of the flow version - [Deployment][google.cloud.dialogflow.cx.v3.Deployment]. - Format: - ``projects//locations//agents// environments//deployments/``. - """ - - environment: 'Environment' = proto.Field( - proto.MESSAGE, - number=1, - message='Environment', - ) - deployment: str = proto.Field( - proto.STRING, - number=2, - ) - - -class DeployFlowMetadata(proto.Message): - r"""Metadata returned for the - [Environments.DeployFlow][google.cloud.dialogflow.cx.v3.Environments.DeployFlow] - long running operation. - - Attributes: - test_errors (MutableSequence[google.cloud.dialogflowcx_v3.types.TestError]): - Errors of running deployment tests. - """ - - test_errors: MutableSequence[test_case.TestError] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=test_case.TestError, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/experiment.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/experiment.py deleted file mode 100644 index eb3a986b..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/experiment.py +++ /dev/null @@ -1,771 +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 field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.dialogflow.cx.v3', - manifest={ - 'Experiment', - 'VersionVariants', - 'VariantsHistory', - 'RolloutConfig', - 'RolloutState', - 'ListExperimentsRequest', - 'ListExperimentsResponse', - 'GetExperimentRequest', - 'CreateExperimentRequest', - 'UpdateExperimentRequest', - 'DeleteExperimentRequest', - 'StartExperimentRequest', - 'StopExperimentRequest', - }, -) - - -class Experiment(proto.Message): - r"""Represents an experiment in an environment. - - Attributes: - name (str): - The name of the experiment. - Format: projects//locations//agents//environments//experiments/.. - display_name (str): - Required. The human-readable name of the - experiment (unique in an environment). Limit of - 64 characters. - description (str): - The human-readable description of the - experiment. - state (google.cloud.dialogflowcx_v3.types.Experiment.State): - The current state of the experiment. - Transition triggered by - Experiments.StartExperiment: DRAFT->RUNNING. - Transition triggered by - Experiments.CancelExperiment: DRAFT->DONE or - RUNNING->DONE. - definition (google.cloud.dialogflowcx_v3.types.Experiment.Definition): - The definition of the experiment. - rollout_config (google.cloud.dialogflowcx_v3.types.RolloutConfig): - The configuration for auto rollout. If set, - there should be exactly two variants in the - experiment (control variant being the default - version of the flow), the traffic allocation for - the non-control variant will gradually increase - to 100% when conditions are met, and eventually - replace the control variant to become the - default version of the flow. - rollout_state (google.cloud.dialogflowcx_v3.types.RolloutState): - State of the auto rollout process. - rollout_failure_reason (str): - The reason why rollout has failed. Should only be set when - state is ROLLOUT_FAILED. - result (google.cloud.dialogflowcx_v3.types.Experiment.Result): - Inference result of the experiment. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Creation time of this experiment. - start_time (google.protobuf.timestamp_pb2.Timestamp): - Start time of this experiment. - end_time (google.protobuf.timestamp_pb2.Timestamp): - End time of this experiment. - last_update_time (google.protobuf.timestamp_pb2.Timestamp): - Last update time of this experiment. - experiment_length (google.protobuf.duration_pb2.Duration): - Maximum number of days to run the - experiment/rollout. If auto-rollout is not - enabled, default value and maximum will be 30 - days. If auto-rollout is enabled, default value - and maximum will be 6 days. - variants_history (MutableSequence[google.cloud.dialogflowcx_v3.types.VariantsHistory]): - The history of updates to the experiment - variants. - """ - class State(proto.Enum): - r"""The state of the experiment. - - Values: - STATE_UNSPECIFIED (0): - State unspecified. - DRAFT (1): - The experiment is created but not started - yet. - RUNNING (2): - The experiment is running. - DONE (3): - The experiment is done. - ROLLOUT_FAILED (4): - The experiment with auto-rollout enabled has - failed. - """ - STATE_UNSPECIFIED = 0 - DRAFT = 1 - RUNNING = 2 - DONE = 3 - ROLLOUT_FAILED = 4 - - class Definition(proto.Message): - r"""Definition of the experiment. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - condition (str): - The condition defines which subset of sessions are selected - for this experiment. If not specified, all sessions are - eligible. E.g. "query_input.language_code=en" See the - `conditions - reference `__. - version_variants (google.cloud.dialogflowcx_v3.types.VersionVariants): - The flow versions as the variants of this - experiment. - - This field is a member of `oneof`_ ``variants``. - """ - - condition: str = proto.Field( - proto.STRING, - number=1, - ) - version_variants: 'VersionVariants' = proto.Field( - proto.MESSAGE, - number=2, - oneof='variants', - message='VersionVariants', - ) - - class Result(proto.Message): - r"""The inference result which includes an objective metric to - optimize and the confidence interval. - - Attributes: - version_metrics (MutableSequence[google.cloud.dialogflowcx_v3.types.Experiment.Result.VersionMetrics]): - Version variants and metrics. - last_update_time (google.protobuf.timestamp_pb2.Timestamp): - The last time the experiment's stats data was - updated. Will have default value if stats have - never been computed for this experiment. - """ - class MetricType(proto.Enum): - r"""Types of ratio-based metric for Dialogflow experiment. - - Values: - METRIC_UNSPECIFIED (0): - Metric unspecified. - CONTAINED_SESSION_NO_CALLBACK_RATE (1): - Percentage of contained sessions without user - calling back in 24 hours. - LIVE_AGENT_HANDOFF_RATE (2): - Percentage of sessions that were handed to a - human agent. - CALLBACK_SESSION_RATE (3): - Percentage of sessions with the same user - calling back. - ABANDONED_SESSION_RATE (4): - Percentage of sessions where user hung up. - SESSION_END_RATE (5): - Percentage of sessions reached Dialogflow 'END_PAGE' or - 'END_SESSION'. - """ - METRIC_UNSPECIFIED = 0 - CONTAINED_SESSION_NO_CALLBACK_RATE = 1 - LIVE_AGENT_HANDOFF_RATE = 2 - CALLBACK_SESSION_RATE = 3 - ABANDONED_SESSION_RATE = 4 - SESSION_END_RATE = 5 - - class CountType(proto.Enum): - r"""Types of count-based metric for Dialogflow experiment. - - Values: - COUNT_TYPE_UNSPECIFIED (0): - Count type unspecified. - TOTAL_NO_MATCH_COUNT (1): - Total number of occurrences of a 'NO_MATCH'. - TOTAL_TURN_COUNT (2): - Total number of turn counts. - AVERAGE_TURN_COUNT (3): - Average turn count in a session. - """ - COUNT_TYPE_UNSPECIFIED = 0 - TOTAL_NO_MATCH_COUNT = 1 - TOTAL_TURN_COUNT = 2 - AVERAGE_TURN_COUNT = 3 - - class ConfidenceInterval(proto.Message): - r"""A confidence interval is a range of possible values for the - experiment objective you are trying to measure. - - Attributes: - confidence_level (float): - The confidence level used to construct the - interval, i.e. there is X% chance that the true - value is within this interval. - ratio (float): - The percent change between an experiment - metric's value and the value for its control. - lower_bound (float): - Lower bound of the interval. - upper_bound (float): - Upper bound of the interval. - """ - - confidence_level: float = proto.Field( - proto.DOUBLE, - number=1, - ) - ratio: float = proto.Field( - proto.DOUBLE, - number=2, - ) - lower_bound: float = proto.Field( - proto.DOUBLE, - number=3, - ) - upper_bound: float = proto.Field( - proto.DOUBLE, - number=4, - ) - - class Metric(proto.Message): - r"""Metric and corresponding confidence intervals. - - 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: - type_ (google.cloud.dialogflowcx_v3.types.Experiment.Result.MetricType): - Ratio-based metric type. Only one of type or count_type is - specified in each Metric. - count_type (google.cloud.dialogflowcx_v3.types.Experiment.Result.CountType): - Count-based metric type. Only one of type or count_type is - specified in each Metric. - ratio (float): - Ratio value of a metric. - - This field is a member of `oneof`_ ``value``. - count (float): - Count value of a metric. - - This field is a member of `oneof`_ ``value``. - confidence_interval (google.cloud.dialogflowcx_v3.types.Experiment.Result.ConfidenceInterval): - The probability that the treatment is better - than all other treatments in the experiment - """ - - type_: 'Experiment.Result.MetricType' = proto.Field( - proto.ENUM, - number=1, - enum='Experiment.Result.MetricType', - ) - count_type: 'Experiment.Result.CountType' = proto.Field( - proto.ENUM, - number=5, - enum='Experiment.Result.CountType', - ) - ratio: float = proto.Field( - proto.DOUBLE, - number=2, - oneof='value', - ) - count: float = proto.Field( - proto.DOUBLE, - number=4, - oneof='value', - ) - confidence_interval: 'Experiment.Result.ConfidenceInterval' = proto.Field( - proto.MESSAGE, - number=3, - message='Experiment.Result.ConfidenceInterval', - ) - - class VersionMetrics(proto.Message): - r"""Version variant and associated metrics. - - Attributes: - version (str): - The name of the flow - [Version][google.cloud.dialogflow.cx.v3.Version]. Format: - ``projects//locations//agents//flows//versions/``. - metrics (MutableSequence[google.cloud.dialogflowcx_v3.types.Experiment.Result.Metric]): - The metrics and corresponding confidence - intervals in the inference result. - session_count (int): - Number of sessions that were allocated to - this version. - """ - - version: str = proto.Field( - proto.STRING, - number=1, - ) - metrics: MutableSequence['Experiment.Result.Metric'] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='Experiment.Result.Metric', - ) - session_count: int = proto.Field( - proto.INT32, - number=3, - ) - - version_metrics: MutableSequence['Experiment.Result.VersionMetrics'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Experiment.Result.VersionMetrics', - ) - last_update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - - name: str = proto.Field( - proto.STRING, - number=1, - ) - display_name: str = proto.Field( - proto.STRING, - number=2, - ) - description: str = proto.Field( - proto.STRING, - number=3, - ) - state: State = proto.Field( - proto.ENUM, - number=4, - enum=State, - ) - definition: Definition = proto.Field( - proto.MESSAGE, - number=5, - message=Definition, - ) - rollout_config: 'RolloutConfig' = proto.Field( - proto.MESSAGE, - number=14, - message='RolloutConfig', - ) - rollout_state: 'RolloutState' = proto.Field( - proto.MESSAGE, - number=15, - message='RolloutState', - ) - rollout_failure_reason: str = proto.Field( - proto.STRING, - number=16, - ) - result: Result = proto.Field( - proto.MESSAGE, - number=6, - message=Result, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - start_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - end_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=9, - message=timestamp_pb2.Timestamp, - ) - last_update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=10, - message=timestamp_pb2.Timestamp, - ) - experiment_length: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=11, - message=duration_pb2.Duration, - ) - variants_history: MutableSequence['VariantsHistory'] = proto.RepeatedField( - proto.MESSAGE, - number=12, - message='VariantsHistory', - ) - - -class VersionVariants(proto.Message): - r"""A list of flow version variants. - - Attributes: - variants (MutableSequence[google.cloud.dialogflowcx_v3.types.VersionVariants.Variant]): - A list of flow version variants. - """ - - class Variant(proto.Message): - r"""A single flow version with specified traffic allocation. - - Attributes: - version (str): - The name of the flow version. Format: - ``projects//locations//agents//flows//versions/``. - traffic_allocation (float): - Percentage of the traffic which should be - routed to this version of flow. Traffic - allocation for a single flow must sum up to 1.0. - is_control_group (bool): - Whether the variant is for the control group. - """ - - version: str = proto.Field( - proto.STRING, - number=1, - ) - traffic_allocation: float = proto.Field( - proto.FLOAT, - number=2, - ) - is_control_group: bool = proto.Field( - proto.BOOL, - number=3, - ) - - variants: MutableSequence[Variant] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=Variant, - ) - - -class VariantsHistory(proto.Message): - r"""The history of variants update. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - version_variants (google.cloud.dialogflowcx_v3.types.VersionVariants): - The flow versions as the variants. - - This field is a member of `oneof`_ ``variants``. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Update time of the variants. - """ - - version_variants: 'VersionVariants' = proto.Field( - proto.MESSAGE, - number=1, - oneof='variants', - message='VersionVariants', - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - - -class RolloutConfig(proto.Message): - r"""The configuration for auto rollout. - - Attributes: - rollout_steps (MutableSequence[google.cloud.dialogflowcx_v3.types.RolloutConfig.RolloutStep]): - Steps to roll out a flow version. Steps - should be sorted by percentage in ascending - order. - rollout_condition (str): - The conditions that are used to evaluate the success of a - rollout step. If not specified, all rollout steps will - proceed to the next one unless failure conditions are met. - E.g. "containment_rate > 60% AND callback_rate < 20%". See - the `conditions - reference `__. - failure_condition (str): - The conditions that are used to evaluate the failure of a - rollout step. If not specified, no rollout steps will fail. - E.g. "containment_rate < 10% OR average_turn_count < 3". See - the `conditions - reference `__. - """ - - class RolloutStep(proto.Message): - r"""A single rollout step with specified traffic allocation. - - Attributes: - display_name (str): - The name of the rollout step; - traffic_percent (int): - The percentage of traffic allocated to the flow version of - this rollout step. (0%, 100%]. - min_duration (google.protobuf.duration_pb2.Duration): - The minimum time that this step should last. - Should be longer than 1 hour. If not set, the - default minimum duration for each step will be 1 - hour. - """ - - display_name: str = proto.Field( - proto.STRING, - number=1, - ) - traffic_percent: int = proto.Field( - proto.INT32, - number=2, - ) - min_duration: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=3, - message=duration_pb2.Duration, - ) - - rollout_steps: MutableSequence[RolloutStep] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=RolloutStep, - ) - rollout_condition: str = proto.Field( - proto.STRING, - number=2, - ) - failure_condition: str = proto.Field( - proto.STRING, - number=3, - ) - - -class RolloutState(proto.Message): - r"""State of the auto-rollout process. - - Attributes: - step (str): - Display name of the current auto rollout - step. - step_index (int): - Index of the current step in the auto rollout - steps list. - start_time (google.protobuf.timestamp_pb2.Timestamp): - Start time of the current step. - """ - - step: str = proto.Field( - proto.STRING, - number=1, - ) - step_index: int = proto.Field( - proto.INT32, - number=3, - ) - start_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - - -class ListExperimentsRequest(proto.Message): - r"""The request message for - [Experiments.ListExperiments][google.cloud.dialogflow.cx.v3.Experiments.ListExperiments]. - - Attributes: - parent (str): - Required. The - [Environment][google.cloud.dialogflow.cx.v3.Environment] to - list all environments for. Format: - ``projects//locations//agents//environments/``. - page_size (int): - The maximum number of items to return in a - single page. By default 20 and at most 100. - page_token (str): - The next_page_token value returned from a previous list - request. - """ - - 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 ListExperimentsResponse(proto.Message): - r"""The response message for - [Experiments.ListExperiments][google.cloud.dialogflow.cx.v3.Experiments.ListExperiments]. - - Attributes: - experiments (MutableSequence[google.cloud.dialogflowcx_v3.types.Experiment]): - The list of experiments. There will be a maximum number of - items returned based on the page_size field in the request. - The list may in some cases be empty or contain fewer entries - than page_size even if this isn't the last page. - next_page_token (str): - Token to retrieve the next page of results, - or empty if there are no more results in the - list. - """ - - @property - def raw_page(self): - return self - - experiments: MutableSequence['Experiment'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Experiment', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetExperimentRequest(proto.Message): - r"""The request message for - [Experiments.GetExperiment][google.cloud.dialogflow.cx.v3.Experiments.GetExperiment]. - - Attributes: - name (str): - Required. The name of the - [Environment][google.cloud.dialogflow.cx.v3.Environment]. - Format: - ``projects//locations//agents//environments//experiments/``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateExperimentRequest(proto.Message): - r"""The request message for - [Experiments.CreateExperiment][google.cloud.dialogflow.cx.v3.Experiments.CreateExperiment]. - - Attributes: - parent (str): - Required. The [Agent][google.cloud.dialogflow.cx.v3.Agent] - to create an - [Environment][google.cloud.dialogflow.cx.v3.Environment] - for. Format: - ``projects//locations//agents//environments/``. - experiment (google.cloud.dialogflowcx_v3.types.Experiment): - Required. The experiment to create. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - experiment: 'Experiment' = proto.Field( - proto.MESSAGE, - number=2, - message='Experiment', - ) - - -class UpdateExperimentRequest(proto.Message): - r"""The request message for - [Experiments.UpdateExperiment][google.cloud.dialogflow.cx.v3.Experiments.UpdateExperiment]. - - Attributes: - experiment (google.cloud.dialogflowcx_v3.types.Experiment): - Required. The experiment to update. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The mask to control which fields - get updated. - """ - - experiment: 'Experiment' = proto.Field( - proto.MESSAGE, - number=1, - message='Experiment', - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteExperimentRequest(proto.Message): - r"""The request message for - [Experiments.DeleteExperiment][google.cloud.dialogflow.cx.v3.Experiments.DeleteExperiment]. - - Attributes: - name (str): - Required. The name of the - [Environment][google.cloud.dialogflow.cx.v3.Environment] to - delete. Format: - ``projects//locations//agents//environments//experiments/``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class StartExperimentRequest(proto.Message): - r"""The request message for - [Experiments.StartExperiment][google.cloud.dialogflow.cx.v3.Experiments.StartExperiment]. - - Attributes: - name (str): - Required. Resource name of the experiment to start. Format: - ``projects//locations//agents//environments//experiments/``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class StopExperimentRequest(proto.Message): - r"""The request message for - [Experiments.StopExperiment][google.cloud.dialogflow.cx.v3.Experiments.StopExperiment]. - - Attributes: - name (str): - Required. Resource name of the experiment to stop. Format: - ``projects//locations//agents//environments//experiments/``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/flow.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/flow.py deleted file mode 100644 index 4c8c6aa0..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/flow.py +++ /dev/null @@ -1,751 +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.dialogflowcx_v3.types import import_strategy -from google.cloud.dialogflowcx_v3.types import page -from google.cloud.dialogflowcx_v3.types import validation_message -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.dialogflow.cx.v3', - manifest={ - 'NluSettings', - 'Flow', - 'CreateFlowRequest', - 'DeleteFlowRequest', - 'ListFlowsRequest', - 'ListFlowsResponse', - 'GetFlowRequest', - 'UpdateFlowRequest', - 'TrainFlowRequest', - 'ValidateFlowRequest', - 'GetFlowValidationResultRequest', - 'FlowValidationResult', - 'ImportFlowRequest', - 'FlowImportStrategy', - 'ImportFlowResponse', - 'ExportFlowRequest', - 'ExportFlowResponse', - }, -) - - -class NluSettings(proto.Message): - r"""Settings related to NLU. - - Attributes: - model_type (google.cloud.dialogflowcx_v3.types.NluSettings.ModelType): - Indicates the type of NLU model. - classification_threshold (float): - To filter out false positive results and - still get variety in matched natural language - inputs for your agent, you can tune the machine - learning classification threshold. If the - returned score value is less than the threshold - value, then a no-match event will be triggered. - The score values range from 0.0 (completely - uncertain) to 1.0 (completely certain). If set - to 0.0, the default of 0.3 is used. - model_training_mode (google.cloud.dialogflowcx_v3.types.NluSettings.ModelTrainingMode): - Indicates NLU model training mode. - """ - class ModelType(proto.Enum): - r"""NLU model type. - - Values: - MODEL_TYPE_UNSPECIFIED (0): - Not specified. ``MODEL_TYPE_STANDARD`` will be used. - MODEL_TYPE_STANDARD (1): - Use standard NLU model. - MODEL_TYPE_ADVANCED (3): - Use advanced NLU model. - """ - MODEL_TYPE_UNSPECIFIED = 0 - MODEL_TYPE_STANDARD = 1 - MODEL_TYPE_ADVANCED = 3 - - class ModelTrainingMode(proto.Enum): - r"""NLU model training mode. - - Values: - MODEL_TRAINING_MODE_UNSPECIFIED (0): - Not specified. ``MODEL_TRAINING_MODE_AUTOMATIC`` will be - used. - MODEL_TRAINING_MODE_AUTOMATIC (1): - NLU model training is automatically triggered - when a flow gets modified. User can also - manually trigger model training in this mode. - MODEL_TRAINING_MODE_MANUAL (2): - User needs to manually trigger NLU model - training. Best for large flows whose models take - long time to train. - """ - MODEL_TRAINING_MODE_UNSPECIFIED = 0 - MODEL_TRAINING_MODE_AUTOMATIC = 1 - MODEL_TRAINING_MODE_MANUAL = 2 - - model_type: ModelType = proto.Field( - proto.ENUM, - number=1, - enum=ModelType, - ) - classification_threshold: float = proto.Field( - proto.FLOAT, - number=3, - ) - model_training_mode: ModelTrainingMode = proto.Field( - proto.ENUM, - number=4, - enum=ModelTrainingMode, - ) - - -class Flow(proto.Message): - r"""Flows represents the conversation flows when you build your - chatbot agent. - A flow consists of many pages connected by the transition - routes. Conversations always start with the built-in Start Flow - (with an all-0 ID). Transition routes can direct the - conversation session from the current flow (parent flow) to - another flow (sub flow). When the sub flow is finished, - Dialogflow will bring the session back to the parent flow, where - the sub flow is started. - - Usually, when a transition route is followed by a matched - intent, the intent will be "consumed". This means the intent - won't activate more transition routes. However, when the - followed transition route moves the conversation session into a - different flow, the matched intent can be carried over and to be - consumed in the target flow. - - Attributes: - name (str): - The unique identifier of the flow. Format: - ``projects//locations//agents//flows/``. - display_name (str): - Required. The human-readable name of the - flow. - description (str): - The description of the flow. The maximum - length is 500 characters. If exceeded, the - request is rejected. - transition_routes (MutableSequence[google.cloud.dialogflowcx_v3.types.TransitionRoute]): - A flow's transition routes serve two purposes: - - - They are responsible for matching the user's first - utterances in the flow. - - They are inherited by every page's [transition - routes][Page.transition_routes] and can support use cases - such as the user saying "help" or "can I talk to a - human?", which can be handled in a common way regardless - of the current page. Transition routes defined in the - page have higher priority than those defined in the flow. - - TransitionRoutes are evalauted in the following order: - - - TransitionRoutes with intent specified. - - TransitionRoutes with only condition specified. - - TransitionRoutes with intent specified are inherited by - pages in the flow. - event_handlers (MutableSequence[google.cloud.dialogflowcx_v3.types.EventHandler]): - A flow's event handlers serve two purposes: - - - They are responsible for handling events (e.g. no match, - webhook errors) in the flow. - - They are inherited by every page's [event - handlers][Page.event_handlers], which can be used to - handle common events regardless of the current page. - Event handlers defined in the page have higher priority - than those defined in the flow. - - Unlike - [transition_routes][google.cloud.dialogflow.cx.v3.Flow.transition_routes], - these handlers are evaluated on a first-match basis. The - first one that matches the event get executed, with the rest - being ignored. - transition_route_groups (MutableSequence[str]): - A flow's transition route group serve two purposes: - - - They are responsible for matching the user's first - utterances in the flow. - - They are inherited by every page's [transition route - groups][Page.transition_route_groups]. Transition route - groups defined in the page have higher priority than - those defined in the flow. - - Format:\ ``projects//locations//agents//flows//transitionRouteGroups/`` - or - ``projects//locations//agents//transitionRouteGroups/`` - for agent-level groups. - nlu_settings (google.cloud.dialogflowcx_v3.types.NluSettings): - NLU related settings of the flow. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - display_name: str = proto.Field( - proto.STRING, - number=2, - ) - description: str = proto.Field( - proto.STRING, - number=3, - ) - transition_routes: MutableSequence[page.TransitionRoute] = proto.RepeatedField( - proto.MESSAGE, - number=4, - message=page.TransitionRoute, - ) - event_handlers: MutableSequence[page.EventHandler] = proto.RepeatedField( - proto.MESSAGE, - number=10, - message=page.EventHandler, - ) - transition_route_groups: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=15, - ) - nlu_settings: 'NluSettings' = proto.Field( - proto.MESSAGE, - number=11, - message='NluSettings', - ) - - -class CreateFlowRequest(proto.Message): - r"""The request message for - [Flows.CreateFlow][google.cloud.dialogflow.cx.v3.Flows.CreateFlow]. - - Attributes: - parent (str): - Required. The agent to create a flow for. Format: - ``projects//locations//agents/``. - flow (google.cloud.dialogflowcx_v3.types.Flow): - Required. The flow to create. - language_code (str): - The language of the following fields in ``flow``: - - - ``Flow.event_handlers.trigger_fulfillment.messages`` - - ``Flow.event_handlers.trigger_fulfillment.conditional_cases`` - - ``Flow.transition_routes.trigger_fulfillment.messages`` - - ``Flow.transition_routes.trigger_fulfillment.conditional_cases`` - - If not specified, the agent's default language is used. - `Many - languages `__ - are supported. Note: languages must be enabled in the agent - before they can be used. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - flow: 'Flow' = proto.Field( - proto.MESSAGE, - number=2, - message='Flow', - ) - language_code: str = proto.Field( - proto.STRING, - number=3, - ) - - -class DeleteFlowRequest(proto.Message): - r"""The request message for - [Flows.DeleteFlow][google.cloud.dialogflow.cx.v3.Flows.DeleteFlow]. - - Attributes: - name (str): - Required. The name of the flow to delete. Format: - ``projects//locations//agents//flows/``. - force (bool): - This field has no effect for flows with no incoming - transitions. For flows with incoming transitions: - - - If ``force`` is set to false, an error will be returned - with message indicating the incoming transitions. - - If ``force`` is set to true, Dialogflow will remove the - flow, as well as any transitions to the flow (i.e. - [Target flow][EventHandler.target_flow] in event handlers - or [Target flow][TransitionRoute.target_flow] in - transition routes that point to this flow will be - cleared). - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - force: bool = proto.Field( - proto.BOOL, - number=2, - ) - - -class ListFlowsRequest(proto.Message): - r"""The request message for - [Flows.ListFlows][google.cloud.dialogflow.cx.v3.Flows.ListFlows]. - - Attributes: - parent (str): - Required. The agent containing the flows. Format: - ``projects//locations//agents/``. - page_size (int): - The maximum number of items to return in a - single page. By default 100 and at most 1000. - page_token (str): - The next_page_token value returned from a previous list - request. - language_code (str): - The language to list flows for. The following fields are - language dependent: - - - ``Flow.event_handlers.trigger_fulfillment.messages`` - - ``Flow.event_handlers.trigger_fulfillment.conditional_cases`` - - ``Flow.transition_routes.trigger_fulfillment.messages`` - - ``Flow.transition_routes.trigger_fulfillment.conditional_cases`` - - If not specified, the agent's default language is used. - `Many - languages `__ - are supported. Note: languages must be enabled in the agent - before they can be used. - """ - - 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, - ) - language_code: str = proto.Field( - proto.STRING, - number=4, - ) - - -class ListFlowsResponse(proto.Message): - r"""The response message for - [Flows.ListFlows][google.cloud.dialogflow.cx.v3.Flows.ListFlows]. - - Attributes: - flows (MutableSequence[google.cloud.dialogflowcx_v3.types.Flow]): - The list of flows. There will be a maximum number of items - returned based on the page_size field in the request. - next_page_token (str): - Token to retrieve the next page of results, - or empty if there are no more results in the - list. - """ - - @property - def raw_page(self): - return self - - flows: MutableSequence['Flow'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Flow', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetFlowRequest(proto.Message): - r"""The response message for - [Flows.GetFlow][google.cloud.dialogflow.cx.v3.Flows.GetFlow]. - - Attributes: - name (str): - Required. The name of the flow to get. Format: - ``projects//locations//agents//flows/``. - language_code (str): - The language to retrieve the flow for. The following fields - are language dependent: - - - ``Flow.event_handlers.trigger_fulfillment.messages`` - - ``Flow.event_handlers.trigger_fulfillment.conditional_cases`` - - ``Flow.transition_routes.trigger_fulfillment.messages`` - - ``Flow.transition_routes.trigger_fulfillment.conditional_cases`` - - If not specified, the agent's default language is used. - `Many - languages `__ - are supported. Note: languages must be enabled in the agent - before they can be used. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - language_code: str = proto.Field( - proto.STRING, - number=2, - ) - - -class UpdateFlowRequest(proto.Message): - r"""The request message for - [Flows.UpdateFlow][google.cloud.dialogflow.cx.v3.Flows.UpdateFlow]. - - Attributes: - flow (google.cloud.dialogflowcx_v3.types.Flow): - Required. The flow to update. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The mask to control which fields get updated. - If the mask is not present, all fields will be - updated. - language_code (str): - The language of the following fields in ``flow``: - - - ``Flow.event_handlers.trigger_fulfillment.messages`` - - ``Flow.event_handlers.trigger_fulfillment.conditional_cases`` - - ``Flow.transition_routes.trigger_fulfillment.messages`` - - ``Flow.transition_routes.trigger_fulfillment.conditional_cases`` - - If not specified, the agent's default language is used. - `Many - languages `__ - are supported. Note: languages must be enabled in the agent - before they can be used. - """ - - flow: 'Flow' = proto.Field( - proto.MESSAGE, - number=1, - message='Flow', - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - language_code: str = proto.Field( - proto.STRING, - number=3, - ) - - -class TrainFlowRequest(proto.Message): - r"""The request message for - [Flows.TrainFlow][google.cloud.dialogflow.cx.v3.Flows.TrainFlow]. - - Attributes: - name (str): - Required. The flow to train. Format: - ``projects//locations//agents//flows/``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ValidateFlowRequest(proto.Message): - r"""The request message for - [Flows.ValidateFlow][google.cloud.dialogflow.cx.v3.Flows.ValidateFlow]. - - Attributes: - name (str): - Required. The flow to validate. Format: - ``projects//locations//agents//flows/``. - language_code (str): - If not specified, the agent's default - language is used. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - language_code: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetFlowValidationResultRequest(proto.Message): - r"""The request message for - [Flows.GetFlowValidationResult][google.cloud.dialogflow.cx.v3.Flows.GetFlowValidationResult]. - - Attributes: - name (str): - Required. The flow name. Format: - ``projects//locations//agents//flows//validationResult``. - language_code (str): - If not specified, the agent's default - language is used. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - language_code: str = proto.Field( - proto.STRING, - number=2, - ) - - -class FlowValidationResult(proto.Message): - r"""The response message for - [Flows.GetFlowValidationResult][google.cloud.dialogflow.cx.v3.Flows.GetFlowValidationResult]. - - Attributes: - name (str): - The unique identifier of the flow validation result. Format: - ``projects//locations//agents//flows//validationResult``. - validation_messages (MutableSequence[google.cloud.dialogflowcx_v3.types.ValidationMessage]): - Contains all validation messages. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Last time the flow was validated. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - validation_messages: MutableSequence[validation_message.ValidationMessage] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message=validation_message.ValidationMessage, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - - -class ImportFlowRequest(proto.Message): - r"""The request message for - [Flows.ImportFlow][google.cloud.dialogflow.cx.v3.Flows.ImportFlow]. - - 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: - parent (str): - Required. The agent to import the flow into. Format: - ``projects//locations//agents/``. - flow_uri (str): - The `Google Cloud - Storage `__ URI to - import flow from. The format of this URI must be - ``gs:///``. - - Dialogflow performs a read operation for the Cloud Storage - object on the caller's behalf, so your request - authentication must have read permissions for the object. - For more information, see `Dialogflow access - control `__. - - This field is a member of `oneof`_ ``flow``. - flow_content (bytes): - Uncompressed raw byte content for flow. - - This field is a member of `oneof`_ ``flow``. - import_option (google.cloud.dialogflowcx_v3.types.ImportFlowRequest.ImportOption): - Flow import mode. If not specified, ``KEEP`` is assumed. - flow_import_strategy (google.cloud.dialogflowcx_v3.types.FlowImportStrategy): - Optional. Specifies the import strategy used - when resolving resource conflicts. - """ - class ImportOption(proto.Enum): - r"""Import option. - - Values: - IMPORT_OPTION_UNSPECIFIED (0): - Unspecified. Treated as ``KEEP``. - KEEP (1): - Always respect settings in exported flow - content. It may cause a import failure if some - settings (e.g. custom NLU) are not supported in - the agent to import into. - FALLBACK (2): - Fallback to default settings if some settings - are not supported in the agent to import into. - E.g. Standard NLU will be used if custom NLU is - not available. - """ - IMPORT_OPTION_UNSPECIFIED = 0 - KEEP = 1 - FALLBACK = 2 - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - flow_uri: str = proto.Field( - proto.STRING, - number=2, - oneof='flow', - ) - flow_content: bytes = proto.Field( - proto.BYTES, - number=3, - oneof='flow', - ) - import_option: ImportOption = proto.Field( - proto.ENUM, - number=4, - enum=ImportOption, - ) - flow_import_strategy: 'FlowImportStrategy' = proto.Field( - proto.MESSAGE, - number=5, - message='FlowImportStrategy', - ) - - -class FlowImportStrategy(proto.Message): - r"""The flow import strategy used for resource conflict resolution - associated with an - [ImportFlowRequest][google.cloud.dialogflow.cx.v3.ImportFlowRequest]. - - Attributes: - global_import_strategy (google.cloud.dialogflowcx_v3.types.ImportStrategy): - Optional. Import strategy for resource conflict resolution, - applied globally throughout the flow. It will be applied for - all display name conflicts in the imported content. If not - specified, 'CREATE_NEW' is assumed. - """ - - global_import_strategy: import_strategy.ImportStrategy = proto.Field( - proto.ENUM, - number=1, - enum=import_strategy.ImportStrategy, - ) - - -class ImportFlowResponse(proto.Message): - r"""The response message for - [Flows.ImportFlow][google.cloud.dialogflow.cx.v3.Flows.ImportFlow]. - - Attributes: - flow (str): - The unique identifier of the new flow. Format: - ``projects//locations//agents//flows/``. - """ - - flow: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ExportFlowRequest(proto.Message): - r"""The request message for - [Flows.ExportFlow][google.cloud.dialogflow.cx.v3.Flows.ExportFlow]. - - Attributes: - name (str): - Required. The name of the flow to export. Format: - ``projects//locations//agents//flows/``. - flow_uri (str): - Optional. The `Google Cloud - Storage `__ URI to - export the flow to. The format of this URI must be - ``gs:///``. If left unspecified, - the serialized flow is returned inline. - - Dialogflow performs a write operation for the Cloud Storage - object on the caller's behalf, so your request - authentication must have write permissions for the object. - For more information, see `Dialogflow access - control `__. - include_referenced_flows (bool): - Optional. Whether to export flows referenced - by the specified flow. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - flow_uri: str = proto.Field( - proto.STRING, - number=2, - ) - include_referenced_flows: bool = proto.Field( - proto.BOOL, - number=4, - ) - - -class ExportFlowResponse(proto.Message): - r"""The response message for - [Flows.ExportFlow][google.cloud.dialogflow.cx.v3.Flows.ExportFlow]. - - 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: - flow_uri (str): - The URI to a file containing the exported flow. This field - is populated only if ``flow_uri`` is specified in - [ExportFlowRequest][google.cloud.dialogflow.cx.v3.ExportFlowRequest]. - - This field is a member of `oneof`_ ``flow``. - flow_content (bytes): - Uncompressed raw byte content for flow. - - This field is a member of `oneof`_ ``flow``. - """ - - flow_uri: str = proto.Field( - proto.STRING, - number=1, - oneof='flow', - ) - flow_content: bytes = proto.Field( - proto.BYTES, - number=2, - oneof='flow', - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/fulfillment.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/fulfillment.py deleted file mode 100644 index bd2e5849..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/fulfillment.py +++ /dev/null @@ -1,220 +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.dialogflowcx_v3.types import response_message -from google.protobuf import struct_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.dialogflow.cx.v3', - manifest={ - 'Fulfillment', - }, -) - - -class Fulfillment(proto.Message): - r"""A fulfillment can do one or more of the following actions at the - same time: - - - Generate rich message responses. - - Set parameter values. - - Call the webhook. - - Fulfillments can be called at various stages in the - [Page][google.cloud.dialogflow.cx.v3.Page] or - [Form][google.cloud.dialogflow.cx.v3.Form] lifecycle. For example, - when a - [DetectIntentRequest][google.cloud.dialogflow.cx.v3.DetectIntentRequest] - drives a session to enter a new page, the page's entry fulfillment - can add a static response to the - [QueryResult][google.cloud.dialogflow.cx.v3.QueryResult] in the - returning - [DetectIntentResponse][google.cloud.dialogflow.cx.v3.DetectIntentResponse], - call the webhook (for example, to load user data from a database), - or both. - - Attributes: - messages (MutableSequence[google.cloud.dialogflowcx_v3.types.ResponseMessage]): - The list of rich message responses to present - to the user. - webhook (str): - The webhook to call. Format: - ``projects//locations//agents//webhooks/``. - return_partial_responses (bool): - Whether Dialogflow should return currently - queued fulfillment response messages in - streaming APIs. If a webhook is specified, it - happens before Dialogflow invokes webhook. - Warning: - - 1) This flag only affects streaming API. - Responses are still queued and returned once in - non-streaming API. - 2) The flag can be enabled in any fulfillment - but only the first 3 partial responses will be - returned. You may only want to apply it to - fulfillments that have slow webhooks. - tag (str): - The value of this field will be populated in the - [WebhookRequest][google.cloud.dialogflow.cx.v3.WebhookRequest] - ``fulfillmentInfo.tag`` field by Dialogflow when the - associated webhook is called. The tag is typically used by - the webhook service to identify which fulfillment is being - called, but it could be used for other purposes. This field - is required if ``webhook`` is specified. - set_parameter_actions (MutableSequence[google.cloud.dialogflowcx_v3.types.Fulfillment.SetParameterAction]): - Set parameter values before executing the - webhook. - conditional_cases (MutableSequence[google.cloud.dialogflowcx_v3.types.Fulfillment.ConditionalCases]): - Conditional cases for this fulfillment. - """ - - class SetParameterAction(proto.Message): - r"""Setting a parameter value. - - Attributes: - parameter (str): - Display name of the parameter. - value (google.protobuf.struct_pb2.Value): - The new value of the parameter. A null value - clears the parameter. - """ - - parameter: str = proto.Field( - proto.STRING, - number=1, - ) - value: struct_pb2.Value = proto.Field( - proto.MESSAGE, - number=2, - message=struct_pb2.Value, - ) - - class ConditionalCases(proto.Message): - r"""A list of cascading if-else conditions. Cases are mutually - exclusive. The first one with a matching condition is selected, - all the rest ignored. - - Attributes: - cases (MutableSequence[google.cloud.dialogflowcx_v3.types.Fulfillment.ConditionalCases.Case]): - A list of cascading if-else conditions. - """ - - class Case(proto.Message): - r"""Each case has a Boolean condition. When it is evaluated to be - True, the corresponding messages will be selected and evaluated - recursively. - - Attributes: - condition (str): - The condition to activate and select this case. Empty means - the condition is always true. The condition is evaluated - against [form parameters][Form.parameters] or [session - parameters][SessionInfo.parameters]. - - See the `conditions - reference `__. - case_content (MutableSequence[google.cloud.dialogflowcx_v3.types.Fulfillment.ConditionalCases.Case.CaseContent]): - A list of case content. - """ - - class CaseContent(proto.Message): - r"""The list of messages or conditional cases to activate for - this case. - - 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: - message (google.cloud.dialogflowcx_v3.types.ResponseMessage): - Returned message. - - This field is a member of `oneof`_ ``cases_or_message``. - additional_cases (google.cloud.dialogflowcx_v3.types.Fulfillment.ConditionalCases): - Additional cases to be evaluated. - - This field is a member of `oneof`_ ``cases_or_message``. - """ - - message: response_message.ResponseMessage = proto.Field( - proto.MESSAGE, - number=1, - oneof='cases_or_message', - message=response_message.ResponseMessage, - ) - additional_cases: 'Fulfillment.ConditionalCases' = proto.Field( - proto.MESSAGE, - number=2, - oneof='cases_or_message', - message='Fulfillment.ConditionalCases', - ) - - condition: str = proto.Field( - proto.STRING, - number=1, - ) - case_content: MutableSequence['Fulfillment.ConditionalCases.Case.CaseContent'] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='Fulfillment.ConditionalCases.Case.CaseContent', - ) - - cases: MutableSequence['Fulfillment.ConditionalCases.Case'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Fulfillment.ConditionalCases.Case', - ) - - messages: MutableSequence[response_message.ResponseMessage] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=response_message.ResponseMessage, - ) - webhook: str = proto.Field( - proto.STRING, - number=2, - ) - return_partial_responses: bool = proto.Field( - proto.BOOL, - number=8, - ) - tag: str = proto.Field( - proto.STRING, - number=3, - ) - set_parameter_actions: MutableSequence[SetParameterAction] = proto.RepeatedField( - proto.MESSAGE, - number=4, - message=SetParameterAction, - ) - conditional_cases: MutableSequence[ConditionalCases] = proto.RepeatedField( - proto.MESSAGE, - number=5, - message=ConditionalCases, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/gcs.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/gcs.py deleted file mode 100644 index f51239bc..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/gcs.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. -# -from __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.dialogflow.cx.v3', - manifest={ - 'GcsDestination', - }, -) - - -class GcsDestination(proto.Message): - r"""Google Cloud Storage location for a Dialogflow operation that - writes or exports objects (e.g. exported agent or transcripts) - outside of Dialogflow. - - Attributes: - uri (str): - Required. The Google Cloud Storage URI for the exported - objects. A URI is of the form: - ``gs://bucket/object-name-or-prefix`` Whether a full object - name, or just a prefix, its usage depends on the Dialogflow - operation. - """ - - uri: str = proto.Field( - proto.STRING, - number=1, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/intent.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/intent.py deleted file mode 100644 index 2b4bcafb..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/intent.py +++ /dev/null @@ -1,489 +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 field_mask_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.dialogflow.cx.v3', - manifest={ - 'IntentView', - 'Intent', - 'ListIntentsRequest', - 'ListIntentsResponse', - 'GetIntentRequest', - 'CreateIntentRequest', - 'UpdateIntentRequest', - 'DeleteIntentRequest', - }, -) - - -class IntentView(proto.Enum): - r"""Represents the options for views of an intent. - An intent can be a sizable object. Therefore, we provide a - resource view that does not return training phrases in the - response. - - Values: - INTENT_VIEW_UNSPECIFIED (0): - Not specified. Treated as INTENT_VIEW_FULL. - INTENT_VIEW_PARTIAL (1): - Training phrases field is not populated in - the response. - INTENT_VIEW_FULL (2): - All fields are populated. - """ - INTENT_VIEW_UNSPECIFIED = 0 - INTENT_VIEW_PARTIAL = 1 - INTENT_VIEW_FULL = 2 - - -class Intent(proto.Message): - r"""An intent represents a user's intent to interact with a - conversational agent. - You can provide information for the Dialogflow API to use to - match user input to an intent by adding training phrases (i.e., - examples of user input) to your intent. - - Attributes: - name (str): - The unique identifier of the intent. Required for the - [Intents.UpdateIntent][google.cloud.dialogflow.cx.v3.Intents.UpdateIntent] - method. - [Intents.CreateIntent][google.cloud.dialogflow.cx.v3.Intents.CreateIntent] - populates the name automatically. Format: - ``projects//locations//agents//intents/``. - display_name (str): - Required. The human-readable name of the - intent, unique within the agent. - training_phrases (MutableSequence[google.cloud.dialogflowcx_v3.types.Intent.TrainingPhrase]): - The collection of training phrases the agent - is trained on to identify the intent. - parameters (MutableSequence[google.cloud.dialogflowcx_v3.types.Intent.Parameter]): - The collection of parameters associated with - the intent. - priority (int): - The priority of this intent. Higher numbers represent higher - priorities. - - - If the supplied value is unspecified or 0, the service - translates the value to 500,000, which corresponds to the - ``Normal`` priority in the console. - - If the supplied value is negative, the intent is ignored - in runtime detect intent requests. - is_fallback (bool): - Indicates whether this is a fallback intent. - Currently only default fallback intent is - allowed in the agent, which is added upon agent - creation. - Adding training phrases to fallback intent is - useful in the case of requests that are - mistakenly matched, since training phrases - assigned to fallback intents act as negative - examples that triggers no-match event. - labels (MutableMapping[str, str]): - The key/value metadata to label an intent. Labels can - contain lowercase letters, digits and the symbols '-' and - '_'. International characters are allowed, including letters - from unicase alphabets. Keys must start with a letter. Keys - and values can be no longer than 63 characters and no more - than 128 bytes. - - Prefix "sys-" is reserved for Dialogflow defined labels. - Currently allowed Dialogflow defined labels include: - - - sys-head - - sys-contextual The above labels do not require value. - "sys-head" means the intent is a head intent. - "sys.contextual" means the intent is a contextual intent. - description (str): - Human readable description for better - understanding an intent like its scope, content, - result etc. Maximum character limit: 140 - characters. - """ - - class TrainingPhrase(proto.Message): - r"""Represents an example that the agent is trained on to - identify the intent. - - Attributes: - id (str): - Output only. The unique identifier of the - training phrase. - parts (MutableSequence[google.cloud.dialogflowcx_v3.types.Intent.TrainingPhrase.Part]): - Required. The ordered list of training phrase parts. The - parts are concatenated in order to form the training phrase. - - Note: The API does not automatically annotate training - phrases like the Dialogflow Console does. - - Note: Do not forget to include whitespace at part - boundaries, so the training phrase is well formatted when - the parts are concatenated. - - If the training phrase does not need to be annotated with - parameters, you just need a single part with only the - [Part.text][google.cloud.dialogflow.cx.v3.Intent.TrainingPhrase.Part.text] - field set. - - If you want to annotate the training phrase, you must create - multiple parts, where the fields of each part are populated - in one of two ways: - - - ``Part.text`` is set to a part of the phrase that has no - parameters. - - ``Part.text`` is set to a part of the phrase that you - want to annotate, and the ``parameter_id`` field is set. - repeat_count (int): - Indicates how many times this example was - added to the intent. - """ - - class Part(proto.Message): - r"""Represents a part of a training phrase. - - Attributes: - text (str): - Required. The text for this part. - parameter_id (str): - The - [parameter][google.cloud.dialogflow.cx.v3.Intent.Parameter] - used to annotate this part of the training phrase. This - field is required for annotated parts of the training - phrase. - """ - - text: str = proto.Field( - proto.STRING, - number=1, - ) - parameter_id: str = proto.Field( - proto.STRING, - number=2, - ) - - id: str = proto.Field( - proto.STRING, - number=1, - ) - parts: MutableSequence['Intent.TrainingPhrase.Part'] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='Intent.TrainingPhrase.Part', - ) - repeat_count: int = proto.Field( - proto.INT32, - number=3, - ) - - class Parameter(proto.Message): - r"""Represents an intent parameter. - - Attributes: - id (str): - Required. The unique identifier of the parameter. This field - is used by [training - phrases][google.cloud.dialogflow.cx.v3.Intent.TrainingPhrase] - to annotate their - [parts][google.cloud.dialogflow.cx.v3.Intent.TrainingPhrase.Part]. - entity_type (str): - Required. The entity type of the parameter. Format: - ``projects/-/locations/-/agents/-/entityTypes/`` - for system entity types (for example, - ``projects/-/locations/-/agents/-/entityTypes/sys.date``), - or - ``projects//locations//agents//entityTypes/`` - for developer entity types. - is_list (bool): - Indicates whether the parameter represents a - list of values. - redact (bool): - Indicates whether the parameter content should be redacted - in log. If redaction is enabled, the parameter content will - be replaced by parameter name during logging. Note: the - parameter content is subject to redaction if either - parameter level redaction or [entity type level - redaction][google.cloud.dialogflow.cx.v3.EntityType.redact] - is enabled. - """ - - id: str = proto.Field( - proto.STRING, - number=1, - ) - entity_type: str = proto.Field( - proto.STRING, - number=2, - ) - is_list: bool = proto.Field( - proto.BOOL, - number=3, - ) - redact: bool = proto.Field( - proto.BOOL, - number=4, - ) - - name: str = proto.Field( - proto.STRING, - number=1, - ) - display_name: str = proto.Field( - proto.STRING, - number=2, - ) - training_phrases: MutableSequence[TrainingPhrase] = proto.RepeatedField( - proto.MESSAGE, - number=3, - message=TrainingPhrase, - ) - parameters: MutableSequence[Parameter] = proto.RepeatedField( - proto.MESSAGE, - number=4, - message=Parameter, - ) - priority: int = proto.Field( - proto.INT32, - number=5, - ) - is_fallback: bool = proto.Field( - proto.BOOL, - number=6, - ) - labels: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=7, - ) - description: str = proto.Field( - proto.STRING, - number=8, - ) - - -class ListIntentsRequest(proto.Message): - r"""The request message for - [Intents.ListIntents][google.cloud.dialogflow.cx.v3.Intents.ListIntents]. - - Attributes: - parent (str): - Required. The agent to list all intents for. Format: - ``projects//locations//agents/``. - language_code (str): - The language to list intents for. The following fields are - language dependent: - - - ``Intent.training_phrases.parts.text`` - - If not specified, the agent's default language is used. - `Many - languages `__ - are supported. Note: languages must be enabled in the agent - before they can be used. - intent_view (google.cloud.dialogflowcx_v3.types.IntentView): - The resource view to apply to the returned - intent. - page_size (int): - The maximum number of items to return in a - single page. By default 100 and at most 1000. - page_token (str): - The next_page_token value returned from a previous list - request. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - language_code: str = proto.Field( - proto.STRING, - number=2, - ) - intent_view: 'IntentView' = proto.Field( - proto.ENUM, - number=5, - enum='IntentView', - ) - page_size: int = proto.Field( - proto.INT32, - number=3, - ) - page_token: str = proto.Field( - proto.STRING, - number=4, - ) - - -class ListIntentsResponse(proto.Message): - r"""The response message for - [Intents.ListIntents][google.cloud.dialogflow.cx.v3.Intents.ListIntents]. - - Attributes: - intents (MutableSequence[google.cloud.dialogflowcx_v3.types.Intent]): - The list of intents. There will be a maximum number of items - returned based on the page_size field in the request. - next_page_token (str): - Token to retrieve the next page of results, - or empty if there are no more results in the - list. - """ - - @property - def raw_page(self): - return self - - intents: MutableSequence['Intent'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Intent', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetIntentRequest(proto.Message): - r"""The request message for - [Intents.GetIntent][google.cloud.dialogflow.cx.v3.Intents.GetIntent]. - - Attributes: - name (str): - Required. The name of the intent. Format: - ``projects//locations//agents//intents/``. - language_code (str): - The language to retrieve the intent for. The following - fields are language dependent: - - - ``Intent.training_phrases.parts.text`` - - If not specified, the agent's default language is used. - `Many - languages `__ - are supported. Note: languages must be enabled in the agent - before they can be used. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - language_code: str = proto.Field( - proto.STRING, - number=2, - ) - - -class CreateIntentRequest(proto.Message): - r"""The request message for - [Intents.CreateIntent][google.cloud.dialogflow.cx.v3.Intents.CreateIntent]. - - Attributes: - parent (str): - Required. The agent to create an intent for. Format: - ``projects//locations//agents/``. - intent (google.cloud.dialogflowcx_v3.types.Intent): - Required. The intent to create. - language_code (str): - The language of the following fields in ``intent``: - - - ``Intent.training_phrases.parts.text`` - - If not specified, the agent's default language is used. - `Many - languages `__ - are supported. Note: languages must be enabled in the agent - before they can be used. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - intent: 'Intent' = proto.Field( - proto.MESSAGE, - number=2, - message='Intent', - ) - language_code: str = proto.Field( - proto.STRING, - number=3, - ) - - -class UpdateIntentRequest(proto.Message): - r"""The request message for - [Intents.UpdateIntent][google.cloud.dialogflow.cx.v3.Intents.UpdateIntent]. - - Attributes: - intent (google.cloud.dialogflowcx_v3.types.Intent): - Required. The intent to update. - language_code (str): - The language of the following fields in ``intent``: - - - ``Intent.training_phrases.parts.text`` - - If not specified, the agent's default language is used. - `Many - languages `__ - are supported. Note: languages must be enabled in the agent - before they can be used. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The mask to control which fields get updated. - If the mask is not present, all fields will be - updated. - """ - - intent: 'Intent' = proto.Field( - proto.MESSAGE, - number=1, - message='Intent', - ) - language_code: str = proto.Field( - proto.STRING, - number=2, - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=3, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteIntentRequest(proto.Message): - r"""The request message for - [Intents.DeleteIntent][google.cloud.dialogflow.cx.v3.Intents.DeleteIntent]. - - Attributes: - name (str): - Required. The name of the intent to delete. Format: - ``projects//locations//agents//intents/``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/page.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/page.py deleted file mode 100644 index ea82228e..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/page.py +++ /dev/null @@ -1,760 +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.dialogflowcx_v3.types import fulfillment -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import struct_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.dialogflow.cx.v3', - manifest={ - 'Page', - 'Form', - 'EventHandler', - 'TransitionRoute', - 'ListPagesRequest', - 'ListPagesResponse', - 'GetPageRequest', - 'CreatePageRequest', - 'UpdatePageRequest', - 'DeletePageRequest', - }, -) - - -class Page(proto.Message): - r"""A Dialogflow CX conversation (session) can be described and - visualized as a state machine. The states of a CX session are - represented by pages. - - For each flow, you define many pages, where your combined pages can - handle a complete conversation on the topics the flow is designed - for. At any given moment, exactly one page is the current page, the - current page is considered active, and the flow associated with that - page is considered active. Every flow has a special start page. When - a flow initially becomes active, the start page page becomes the - current page. For each conversational turn, the current page will - either stay the same or transition to another page. - - You configure each page to collect information from the end-user - that is relevant for the conversational state represented by the - page. - - For more information, see the `Page - guide `__. - - Attributes: - name (str): - The unique identifier of the page. Required for the - [Pages.UpdatePage][google.cloud.dialogflow.cx.v3.Pages.UpdatePage] - method. - [Pages.CreatePage][google.cloud.dialogflow.cx.v3.Pages.CreatePage] - populates the name automatically. Format: - ``projects//locations//agents//flows//pages/``. - display_name (str): - Required. The human-readable name of the - page, unique within the flow. - entry_fulfillment (google.cloud.dialogflowcx_v3.types.Fulfillment): - The fulfillment to call when the session is - entering the page. - form (google.cloud.dialogflowcx_v3.types.Form): - The form associated with the page, used for - collecting parameters relevant to the page. - transition_route_groups (MutableSequence[str]): - Ordered list of - [``TransitionRouteGroups``][google.cloud.dialogflow.cx.v3.TransitionRouteGroup] - associated with the page. Transition route groups must be - unique within a page. - - - If multiple transition routes within a page scope refer - to the same intent, then the precedence order is: page's - transition route -> page's transition route group -> - flow's transition routes. - - - If multiple transition route groups within a page contain - the same intent, then the first group in the ordered list - takes precedence. - - Format:\ ``projects//locations//agents//flows//transitionRouteGroups/`` - or - ``projects//locations//agents//transitionRouteGroups/`` - for agent-level groups. - transition_routes (MutableSequence[google.cloud.dialogflowcx_v3.types.TransitionRoute]): - A list of transitions for the transition rules of this page. - They route the conversation to another page in the same - flow, or another flow. - - When we are in a certain page, the TransitionRoutes are - evalauted in the following order: - - - TransitionRoutes defined in the page with intent - specified. - - TransitionRoutes defined in the [transition route - groups][google.cloud.dialogflow.cx.v3.Page.transition_route_groups] - with intent specified. - - TransitionRoutes defined in flow with intent specified. - - TransitionRoutes defined in the [transition route - groups][google.cloud.dialogflow.cx.v3.Flow.transition_route_groups] - with intent specified. - - TransitionRoutes defined in the page with only condition - specified. - - TransitionRoutes defined in the [transition route - groups][google.cloud.dialogflow.cx.v3.Page.transition_route_groups] - with only condition specified. - event_handlers (MutableSequence[google.cloud.dialogflowcx_v3.types.EventHandler]): - Handlers associated with the page to handle - events such as webhook errors, no match or no - input. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - display_name: str = proto.Field( - proto.STRING, - number=2, - ) - entry_fulfillment: fulfillment.Fulfillment = proto.Field( - proto.MESSAGE, - number=7, - message=fulfillment.Fulfillment, - ) - form: 'Form' = proto.Field( - proto.MESSAGE, - number=4, - message='Form', - ) - transition_route_groups: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=11, - ) - transition_routes: MutableSequence['TransitionRoute'] = proto.RepeatedField( - proto.MESSAGE, - number=9, - message='TransitionRoute', - ) - event_handlers: MutableSequence['EventHandler'] = proto.RepeatedField( - proto.MESSAGE, - number=10, - message='EventHandler', - ) - - -class Form(proto.Message): - r"""A form is a data model that groups related parameters that can be - collected from the user. The process in which the agent prompts the - user and collects parameter values from the user is called form - filling. A form can be added to a - [page][google.cloud.dialogflow.cx.v3.Page]. When form filling is - done, the filled parameters will be written to the - [session][google.cloud.dialogflow.cx.v3.SessionInfo.parameters]. - - Attributes: - parameters (MutableSequence[google.cloud.dialogflowcx_v3.types.Form.Parameter]): - Parameters to collect from the user. - """ - - class Parameter(proto.Message): - r"""Represents a form parameter. - - Attributes: - display_name (str): - Required. The human-readable name of the - parameter, unique within the form. - required (bool): - Indicates whether the parameter is required. - Optional parameters will not trigger prompts; - however, they are filled if the user specifies - them. Required parameters must be filled before - form filling concludes. - entity_type (str): - Required. The entity type of the parameter. Format: - ``projects/-/locations/-/agents/-/entityTypes/`` - for system entity types (for example, - ``projects/-/locations/-/agents/-/entityTypes/sys.date``), - or - ``projects//locations//agents//entityTypes/`` - for developer entity types. - is_list (bool): - Indicates whether the parameter represents a - list of values. - fill_behavior (google.cloud.dialogflowcx_v3.types.Form.Parameter.FillBehavior): - Required. Defines fill behavior for the - parameter. - default_value (google.protobuf.struct_pb2.Value): - The default value of an optional parameter. - If the parameter is required, the default value - will be ignored. - redact (bool): - Indicates whether the parameter content should be redacted - in log. If redaction is enabled, the parameter content will - be replaced by parameter name during logging. Note: the - parameter content is subject to redaction if either - parameter level redaction or [entity type level - redaction][google.cloud.dialogflow.cx.v3.EntityType.redact] - is enabled. - """ - - class FillBehavior(proto.Message): - r"""Configuration for how the filling of a parameter should be - handled. - - Attributes: - initial_prompt_fulfillment (google.cloud.dialogflowcx_v3.types.Fulfillment): - Required. The fulfillment to provide the - initial prompt that the agent can present to the - user in order to fill the parameter. - reprompt_event_handlers (MutableSequence[google.cloud.dialogflowcx_v3.types.EventHandler]): - The handlers for parameter-level events, used to provide - reprompt for the parameter or transition to a different - page/flow. The supported events are: - - - ``sys.no-match-``, where N can be from 1 to 6 - - ``sys.no-match-default`` - - ``sys.no-input-``, where N can be from 1 to 6 - - ``sys.no-input-default`` - - ``sys.invalid-parameter`` - - ``initial_prompt_fulfillment`` provides the first prompt for - the parameter. - - If the user's response does not fill the parameter, a - no-match/no-input event will be triggered, and the - fulfillment associated with the - ``sys.no-match-1``/``sys.no-input-1`` handler (if defined) - will be called to provide a prompt. The - ``sys.no-match-2``/``sys.no-input-2`` handler (if defined) - will respond to the next no-match/no-input event, and so on. - - A ``sys.no-match-default`` or ``sys.no-input-default`` - handler will be used to handle all following - no-match/no-input events after all numbered - no-match/no-input handlers for the parameter are consumed. - - A ``sys.invalid-parameter`` handler can be defined to handle - the case where the parameter values have been - ``invalidated`` by webhook. For example, if the user's - response fill the parameter, however the parameter was - invalidated by webhook, the fulfillment associated with the - ``sys.invalid-parameter`` handler (if defined) will be - called to provide a prompt. - - If the event handler for the corresponding event can't be - found on the parameter, ``initial_prompt_fulfillment`` will - be re-prompted. - """ - - initial_prompt_fulfillment: fulfillment.Fulfillment = proto.Field( - proto.MESSAGE, - number=3, - message=fulfillment.Fulfillment, - ) - reprompt_event_handlers: MutableSequence['EventHandler'] = proto.RepeatedField( - proto.MESSAGE, - number=5, - message='EventHandler', - ) - - display_name: str = proto.Field( - proto.STRING, - number=1, - ) - required: bool = proto.Field( - proto.BOOL, - number=2, - ) - entity_type: str = proto.Field( - proto.STRING, - number=3, - ) - is_list: bool = proto.Field( - proto.BOOL, - number=4, - ) - fill_behavior: 'Form.Parameter.FillBehavior' = proto.Field( - proto.MESSAGE, - number=7, - message='Form.Parameter.FillBehavior', - ) - default_value: struct_pb2.Value = proto.Field( - proto.MESSAGE, - number=9, - message=struct_pb2.Value, - ) - redact: bool = proto.Field( - proto.BOOL, - number=11, - ) - - parameters: MutableSequence[Parameter] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=Parameter, - ) - - -class EventHandler(proto.Message): - r"""An event handler specifies an - [event][google.cloud.dialogflow.cx.v3.EventHandler.event] that can - be handled during a session. When the specified event happens, the - following actions are taken in order: - - - If there is a - [``trigger_fulfillment``][google.cloud.dialogflow.cx.v3.EventHandler.trigger_fulfillment] - associated with the event, it will be called. - - If there is a - [``target_page``][google.cloud.dialogflow.cx.v3.EventHandler.target_page] - associated with the event, the session will transition into the - specified page. - - If there is a - [``target_flow``][google.cloud.dialogflow.cx.v3.EventHandler.target_flow] - associated with the event, the session will transition into the - specified flow. - - 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: - name (str): - Output only. The unique identifier of this - event handler. - event (str): - Required. The name of the event to handle. - trigger_fulfillment (google.cloud.dialogflowcx_v3.types.Fulfillment): - The fulfillment to call when the event - occurs. Handling webhook errors with a - fulfillment enabled with webhook could cause - infinite loop. It is invalid to specify such - fulfillment for a handler handling webhooks. - target_page (str): - The target page to transition to. Format: - ``projects//locations//agents//flows//pages/``. - - This field is a member of `oneof`_ ``target``. - target_flow (str): - The target flow to transition to. Format: - ``projects//locations//agents//flows/``. - - This field is a member of `oneof`_ ``target``. - """ - - name: str = proto.Field( - proto.STRING, - number=6, - ) - event: str = proto.Field( - proto.STRING, - number=4, - ) - trigger_fulfillment: fulfillment.Fulfillment = proto.Field( - proto.MESSAGE, - number=5, - message=fulfillment.Fulfillment, - ) - target_page: str = proto.Field( - proto.STRING, - number=2, - oneof='target', - ) - target_flow: str = proto.Field( - proto.STRING, - number=3, - oneof='target', - ) - - -class TransitionRoute(proto.Message): - r"""A transition route specifies a - [intent][google.cloud.dialogflow.cx.v3.Intent] that can be matched - and/or a data condition that can be evaluated during a session. When - a specified transition is matched, the following actions are taken - in order: - - - If there is a - [``trigger_fulfillment``][google.cloud.dialogflow.cx.v3.TransitionRoute.trigger_fulfillment] - associated with the transition, it will be called. - - If there is a - [``target_page``][google.cloud.dialogflow.cx.v3.TransitionRoute.target_page] - associated with the transition, the session will transition into - the specified page. - - If there is a - [``target_flow``][google.cloud.dialogflow.cx.v3.TransitionRoute.target_flow] - associated with the transition, the session will transition into - the specified flow. - - 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: - name (str): - Output only. The unique identifier of this - transition route. - intent (str): - The unique identifier of an - [Intent][google.cloud.dialogflow.cx.v3.Intent]. Format: - ``projects//locations//agents//intents/``. - Indicates that the transition can only happen when the given - intent is matched. At least one of ``intent`` or - ``condition`` must be specified. When both ``intent`` and - ``condition`` are specified, the transition can only happen - when both are fulfilled. - condition (str): - The condition to evaluate against [form - parameters][google.cloud.dialogflow.cx.v3.Form.parameters] - or [session - parameters][google.cloud.dialogflow.cx.v3.SessionInfo.parameters]. - - See the `conditions - reference `__. - At least one of ``intent`` or ``condition`` must be - specified. When both ``intent`` and ``condition`` are - specified, the transition can only happen when both are - fulfilled. - trigger_fulfillment (google.cloud.dialogflowcx_v3.types.Fulfillment): - The fulfillment to call when the condition is satisfied. At - least one of ``trigger_fulfillment`` and ``target`` must be - specified. When both are defined, ``trigger_fulfillment`` is - executed first. - target_page (str): - The target page to transition to. Format: - ``projects//locations//agents//flows//pages/``. - - This field is a member of `oneof`_ ``target``. - target_flow (str): - The target flow to transition to. Format: - ``projects//locations//agents//flows/``. - - This field is a member of `oneof`_ ``target``. - """ - - name: str = proto.Field( - proto.STRING, - number=6, - ) - intent: str = proto.Field( - proto.STRING, - number=1, - ) - condition: str = proto.Field( - proto.STRING, - number=2, - ) - trigger_fulfillment: fulfillment.Fulfillment = proto.Field( - proto.MESSAGE, - number=3, - message=fulfillment.Fulfillment, - ) - target_page: str = proto.Field( - proto.STRING, - number=4, - oneof='target', - ) - target_flow: str = proto.Field( - proto.STRING, - number=5, - oneof='target', - ) - - -class ListPagesRequest(proto.Message): - r"""The request message for - [Pages.ListPages][google.cloud.dialogflow.cx.v3.Pages.ListPages]. - - Attributes: - parent (str): - Required. The flow to list all pages for. Format: - ``projects//locations//agents//flows/``. - language_code (str): - The language to list pages for. The following fields are - language dependent: - - - ``Page.entry_fulfillment.messages`` - - ``Page.entry_fulfillment.conditional_cases`` - - ``Page.event_handlers.trigger_fulfillment.messages`` - - ``Page.event_handlers.trigger_fulfillment.conditional_cases`` - - ``Page.form.parameters.fill_behavior.initial_prompt_fulfillment.messages`` - - - - ``Page.form.parameters.fill_behavior.initial_prompt_fulfillment.conditional_cases`` - - - ``Page.form.parameters.fill_behavior.reprompt_event_handlers.messages`` - - - - ``Page.form.parameters.fill_behavior.reprompt_event_handlers.conditional_cases`` - - - ``Page.transition_routes.trigger_fulfillment.messages`` - - ``Page.transition_routes.trigger_fulfillment.conditional_cases`` - - If not specified, the agent's default language is used. - `Many - languages `__ - are supported. Note: languages must be enabled in the agent - before they can be used. - page_size (int): - The maximum number of items to return in a - single page. By default 100 and at most 1000. - page_token (str): - The next_page_token value returned from a previous list - request. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - language_code: str = proto.Field( - proto.STRING, - number=2, - ) - page_size: int = proto.Field( - proto.INT32, - number=3, - ) - page_token: str = proto.Field( - proto.STRING, - number=4, - ) - - -class ListPagesResponse(proto.Message): - r"""The response message for - [Pages.ListPages][google.cloud.dialogflow.cx.v3.Pages.ListPages]. - - Attributes: - pages (MutableSequence[google.cloud.dialogflowcx_v3.types.Page]): - The list of pages. There will be a maximum number of items - returned based on the page_size field in the request. - next_page_token (str): - Token to retrieve the next page of results, - or empty if there are no more results in the - list. - """ - - @property - def raw_page(self): - return self - - pages: MutableSequence['Page'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Page', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetPageRequest(proto.Message): - r"""The request message for - [Pages.GetPage][google.cloud.dialogflow.cx.v3.Pages.GetPage]. - - Attributes: - name (str): - Required. The name of the page. Format: - ``projects//locations//agents//flows//pages/``. - language_code (str): - The language to retrieve the page for. The following fields - are language dependent: - - - ``Page.entry_fulfillment.messages`` - - ``Page.entry_fulfillment.conditional_cases`` - - ``Page.event_handlers.trigger_fulfillment.messages`` - - ``Page.event_handlers.trigger_fulfillment.conditional_cases`` - - ``Page.form.parameters.fill_behavior.initial_prompt_fulfillment.messages`` - - - - ``Page.form.parameters.fill_behavior.initial_prompt_fulfillment.conditional_cases`` - - - ``Page.form.parameters.fill_behavior.reprompt_event_handlers.messages`` - - - - ``Page.form.parameters.fill_behavior.reprompt_event_handlers.conditional_cases`` - - - ``Page.transition_routes.trigger_fulfillment.messages`` - - ``Page.transition_routes.trigger_fulfillment.conditional_cases`` - - If not specified, the agent's default language is used. - `Many - languages `__ - are supported. Note: languages must be enabled in the agent - before they can be used. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - language_code: str = proto.Field( - proto.STRING, - number=2, - ) - - -class CreatePageRequest(proto.Message): - r"""The request message for - [Pages.CreatePage][google.cloud.dialogflow.cx.v3.Pages.CreatePage]. - - Attributes: - parent (str): - Required. The flow to create a page for. Format: - ``projects//locations//agents//flows/``. - page (google.cloud.dialogflowcx_v3.types.Page): - Required. The page to create. - language_code (str): - The language of the following fields in ``page``: - - - ``Page.entry_fulfillment.messages`` - - ``Page.entry_fulfillment.conditional_cases`` - - ``Page.event_handlers.trigger_fulfillment.messages`` - - ``Page.event_handlers.trigger_fulfillment.conditional_cases`` - - ``Page.form.parameters.fill_behavior.initial_prompt_fulfillment.messages`` - - - - ``Page.form.parameters.fill_behavior.initial_prompt_fulfillment.conditional_cases`` - - - ``Page.form.parameters.fill_behavior.reprompt_event_handlers.messages`` - - - - ``Page.form.parameters.fill_behavior.reprompt_event_handlers.conditional_cases`` - - - ``Page.transition_routes.trigger_fulfillment.messages`` - - ``Page.transition_routes.trigger_fulfillment.conditional_cases`` - - If not specified, the agent's default language is used. - `Many - languages `__ - are supported. Note: languages must be enabled in the agent - before they can be used. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - page: 'Page' = proto.Field( - proto.MESSAGE, - number=2, - message='Page', - ) - language_code: str = proto.Field( - proto.STRING, - number=3, - ) - - -class UpdatePageRequest(proto.Message): - r"""The request message for - [Pages.UpdatePage][google.cloud.dialogflow.cx.v3.Pages.UpdatePage]. - - Attributes: - page (google.cloud.dialogflowcx_v3.types.Page): - Required. The page to update. - language_code (str): - The language of the following fields in ``page``: - - - ``Page.entry_fulfillment.messages`` - - ``Page.entry_fulfillment.conditional_cases`` - - ``Page.event_handlers.trigger_fulfillment.messages`` - - ``Page.event_handlers.trigger_fulfillment.conditional_cases`` - - ``Page.form.parameters.fill_behavior.initial_prompt_fulfillment.messages`` - - - - ``Page.form.parameters.fill_behavior.initial_prompt_fulfillment.conditional_cases`` - - - ``Page.form.parameters.fill_behavior.reprompt_event_handlers.messages`` - - - - ``Page.form.parameters.fill_behavior.reprompt_event_handlers.conditional_cases`` - - - ``Page.transition_routes.trigger_fulfillment.messages`` - - ``Page.transition_routes.trigger_fulfillment.conditional_cases`` - - If not specified, the agent's default language is used. - `Many - languages `__ - are supported. Note: languages must be enabled in the agent - before they can be used. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The mask to control which fields get updated. - If the mask is not present, all fields will be - updated. - """ - - page: 'Page' = proto.Field( - proto.MESSAGE, - number=1, - message='Page', - ) - language_code: str = proto.Field( - proto.STRING, - number=2, - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=3, - message=field_mask_pb2.FieldMask, - ) - - -class DeletePageRequest(proto.Message): - r"""The request message for - [Pages.DeletePage][google.cloud.dialogflow.cx.v3.Pages.DeletePage]. - - Attributes: - name (str): - Required. The name of the page to delete. Format: - ``projects//locations//agents//Flows//pages/``. - force (bool): - This field has no effect for pages with no incoming - transitions. For pages with incoming transitions: - - - If ``force`` is set to false, an error will be returned - with message indicating the incoming transitions. - - If ``force`` is set to true, Dialogflow will remove the - page, as well as any transitions to the page (i.e. - [Target page][EventHandler.target_page] in event handlers - or [Target page][TransitionRoute.target_page] in - transition routes that point to this page will be - cleared). - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - force: bool = proto.Field( - proto.BOOL, - number=2, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/response_message.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/response_message.py deleted file mode 100644 index b3a18196..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/response_message.py +++ /dev/null @@ -1,465 +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 struct_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.dialogflow.cx.v3', - manifest={ - 'ResponseMessage', - }, -) - - -class ResponseMessage(proto.Message): - r"""Represents a response message that can be returned by a - conversational agent. - - Response messages are also used for output audio synthesis. The - approach is as follows: - - - If at least one OutputAudioText response is present, then all - OutputAudioText responses are linearly concatenated, and the - result is used for output audio synthesis. - - If the OutputAudioText responses are a mixture of text and SSML, - then the concatenated result is treated as SSML; otherwise, the - result is treated as either text or SSML as appropriate. The - agent designer should ideally use either text or SSML - consistently throughout the bot design. - - Otherwise, all Text responses are linearly concatenated, and the - result is used for output audio synthesis. - - This approach allows for more sophisticated user experience - scenarios, where the text displayed to the user may differ from what - is heard. - - 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: - text (google.cloud.dialogflowcx_v3.types.ResponseMessage.Text): - Returns a text response. - - This field is a member of `oneof`_ ``message``. - payload (google.protobuf.struct_pb2.Struct): - Returns a response containing a custom, - platform-specific payload. - - This field is a member of `oneof`_ ``message``. - conversation_success (google.cloud.dialogflowcx_v3.types.ResponseMessage.ConversationSuccess): - Indicates that the conversation succeeded. - - This field is a member of `oneof`_ ``message``. - output_audio_text (google.cloud.dialogflowcx_v3.types.ResponseMessage.OutputAudioText): - A text or ssml response that is - preferentially used for TTS output audio - synthesis, as described in the comment on the - ResponseMessage message. - - This field is a member of `oneof`_ ``message``. - live_agent_handoff (google.cloud.dialogflowcx_v3.types.ResponseMessage.LiveAgentHandoff): - Hands off conversation to a human agent. - - This field is a member of `oneof`_ ``message``. - end_interaction (google.cloud.dialogflowcx_v3.types.ResponseMessage.EndInteraction): - Output only. A signal that indicates the interaction with - the Dialogflow agent has ended. This message is generated by - Dialogflow only when the conversation reaches - ``END_SESSION`` page. It is not supposed to be defined by - the user. - - It's guaranteed that there is at most one such message in - each response. - - This field is a member of `oneof`_ ``message``. - play_audio (google.cloud.dialogflowcx_v3.types.ResponseMessage.PlayAudio): - Signal that the client should play an audio clip hosted at a - client-specific URI. Dialogflow uses this to construct - [mixed_audio][google.cloud.dialogflow.cx.v3.ResponseMessage.mixed_audio]. - However, Dialogflow itself does not try to read or process - the URI in any way. - - This field is a member of `oneof`_ ``message``. - mixed_audio (google.cloud.dialogflowcx_v3.types.ResponseMessage.MixedAudio): - Output only. An audio response message composed of both the - synthesized Dialogflow agent responses and responses defined - via - [play_audio][google.cloud.dialogflow.cx.v3.ResponseMessage.play_audio]. - This message is generated by Dialogflow only and not - supposed to be defined by the user. - - This field is a member of `oneof`_ ``message``. - telephony_transfer_call (google.cloud.dialogflowcx_v3.types.ResponseMessage.TelephonyTransferCall): - A signal that the client should transfer the - phone call connected to this agent to a - third-party endpoint. - - This field is a member of `oneof`_ ``message``. - response_type (google.cloud.dialogflowcx_v3.types.ResponseMessage.ResponseType): - Response type. - channel (str): - The channel which the response is associated with. Clients - can specify the channel via - [QueryParameters.channel][google.cloud.dialogflow.cx.v3.QueryParameters.channel], - and only associated channel response will be returned. - """ - class ResponseType(proto.Enum): - r"""Represents different response types. - - Values: - RESPONSE_TYPE_UNSPECIFIED (0): - Not specified. - ENTRY_PROMPT (1): - The response is from an [entry - prompt][google.cloud.dialogflow.cx.v3.Page.entry_fulfillment] - in the page. - PARAMETER_PROMPT (2): - The response is from [form-filling - prompt][google.cloud.dialogflow.cx.v3.Form.Parameter.fill_behavior] - in the page. - HANDLER_PROMPT (3): - The response is from a [transition - route][google.cloud.dialogflow.cx.v3.TransitionRoute] or an - [event handler][EventHandler] in the page or flow or - transition route group. - """ - RESPONSE_TYPE_UNSPECIFIED = 0 - ENTRY_PROMPT = 1 - PARAMETER_PROMPT = 2 - HANDLER_PROMPT = 3 - - class Text(proto.Message): - r"""The text response message. - - Attributes: - text (MutableSequence[str]): - Required. A collection of text responses. - allow_playback_interruption (bool): - Output only. Whether the playback of this - message can be interrupted by the end user's - speech and the client can then starts the next - Dialogflow request. - """ - - text: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=1, - ) - allow_playback_interruption: bool = proto.Field( - proto.BOOL, - number=2, - ) - - class LiveAgentHandoff(proto.Message): - r"""Indicates that the conversation should be handed off to a live - agent. - - Dialogflow only uses this to determine which conversations were - handed off to a human agent for measurement purposes. What else to - do with this signal is up to you and your handoff procedures. - - You may set this, for example: - - - In the - [entry_fulfillment][google.cloud.dialogflow.cx.v3.Page.entry_fulfillment] - of a [Page][google.cloud.dialogflow.cx.v3.Page] if entering the - page indicates something went extremely wrong in the - conversation. - - In a webhook response when you determine that the customer issue - can only be handled by a human. - - Attributes: - metadata (google.protobuf.struct_pb2.Struct): - Custom metadata for your handoff procedure. - Dialogflow doesn't impose any structure on this. - """ - - metadata: struct_pb2.Struct = proto.Field( - proto.MESSAGE, - number=1, - message=struct_pb2.Struct, - ) - - class ConversationSuccess(proto.Message): - r"""Indicates that the conversation succeeded, i.e., the bot handled the - issue that the customer talked to it about. - - Dialogflow only uses this to determine which conversations should be - counted as successful and doesn't process the metadata in this - message in any way. Note that Dialogflow also considers - conversations that get to the conversation end page as successful - even if they don't return - [ConversationSuccess][google.cloud.dialogflow.cx.v3.ResponseMessage.ConversationSuccess]. - - You may set this, for example: - - - In the - [entry_fulfillment][google.cloud.dialogflow.cx.v3.Page.entry_fulfillment] - of a [Page][google.cloud.dialogflow.cx.v3.Page] if entering the - page indicates that the conversation succeeded. - - In a webhook response when you determine that you handled the - customer issue. - - Attributes: - metadata (google.protobuf.struct_pb2.Struct): - Custom metadata. Dialogflow doesn't impose - any structure on this. - """ - - metadata: struct_pb2.Struct = proto.Field( - proto.MESSAGE, - number=1, - message=struct_pb2.Struct, - ) - - class OutputAudioText(proto.Message): - r"""A text or ssml response that is preferentially used for TTS - output audio synthesis, as described in the comment on the - ResponseMessage message. - - 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: - text (str): - The raw text to be synthesized. - - This field is a member of `oneof`_ ``source``. - ssml (str): - The SSML text to be synthesized. For more information, see - `SSML `__. - - This field is a member of `oneof`_ ``source``. - allow_playback_interruption (bool): - Output only. Whether the playback of this - message can be interrupted by the end user's - speech and the client can then starts the next - Dialogflow request. - """ - - text: str = proto.Field( - proto.STRING, - number=1, - oneof='source', - ) - ssml: str = proto.Field( - proto.STRING, - number=2, - oneof='source', - ) - allow_playback_interruption: bool = proto.Field( - proto.BOOL, - number=3, - ) - - class EndInteraction(proto.Message): - r"""Indicates that interaction with the Dialogflow agent has - ended. This message is generated by Dialogflow only and not - supposed to be defined by the user. - - """ - - class PlayAudio(proto.Message): - r"""Specifies an audio clip to be played by the client as part of - the response. - - Attributes: - audio_uri (str): - Required. URI of the audio clip. Dialogflow - does not impose any validation on this value. It - is specific to the client that reads it. - allow_playback_interruption (bool): - Output only. Whether the playback of this - message can be interrupted by the end user's - speech and the client can then starts the next - Dialogflow request. - """ - - audio_uri: str = proto.Field( - proto.STRING, - number=1, - ) - allow_playback_interruption: bool = proto.Field( - proto.BOOL, - number=2, - ) - - class MixedAudio(proto.Message): - r"""Represents an audio message that is composed of both segments - synthesized from the Dialogflow agent prompts and ones hosted - externally at the specified URIs. The external URIs are specified - via - [play_audio][google.cloud.dialogflow.cx.v3.ResponseMessage.play_audio]. - This message is generated by Dialogflow only and not supposed to be - defined by the user. - - Attributes: - segments (MutableSequence[google.cloud.dialogflowcx_v3.types.ResponseMessage.MixedAudio.Segment]): - Segments this audio response is composed of. - """ - - class Segment(proto.Message): - r"""Represents one segment of 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: - audio (bytes): - Raw audio synthesized from the Dialogflow - agent's response using the output config - specified in the request. - - This field is a member of `oneof`_ ``content``. - uri (str): - Client-specific URI that points to an audio - clip accessible to the client. Dialogflow does - not impose any validation on it. - - This field is a member of `oneof`_ ``content``. - allow_playback_interruption (bool): - Output only. Whether the playback of this - segment can be interrupted by the end user's - speech and the client should then start the next - Dialogflow request. - """ - - audio: bytes = proto.Field( - proto.BYTES, - number=1, - oneof='content', - ) - uri: str = proto.Field( - proto.STRING, - number=2, - oneof='content', - ) - allow_playback_interruption: bool = proto.Field( - proto.BOOL, - number=3, - ) - - segments: MutableSequence['ResponseMessage.MixedAudio.Segment'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='ResponseMessage.MixedAudio.Segment', - ) - - class TelephonyTransferCall(proto.Message): - r"""Represents the signal that telles the client to transfer the - phone call connected to the agent to a third-party endpoint. - - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - phone_number (str): - Transfer the call to a phone number in `E.164 - format `__. - - This field is a member of `oneof`_ ``endpoint``. - """ - - phone_number: str = proto.Field( - proto.STRING, - number=1, - oneof='endpoint', - ) - - text: Text = proto.Field( - proto.MESSAGE, - number=1, - oneof='message', - message=Text, - ) - payload: struct_pb2.Struct = proto.Field( - proto.MESSAGE, - number=2, - oneof='message', - message=struct_pb2.Struct, - ) - conversation_success: ConversationSuccess = proto.Field( - proto.MESSAGE, - number=9, - oneof='message', - message=ConversationSuccess, - ) - output_audio_text: OutputAudioText = proto.Field( - proto.MESSAGE, - number=8, - oneof='message', - message=OutputAudioText, - ) - live_agent_handoff: LiveAgentHandoff = proto.Field( - proto.MESSAGE, - number=10, - oneof='message', - message=LiveAgentHandoff, - ) - end_interaction: EndInteraction = proto.Field( - proto.MESSAGE, - number=11, - oneof='message', - message=EndInteraction, - ) - play_audio: PlayAudio = proto.Field( - proto.MESSAGE, - number=12, - oneof='message', - message=PlayAudio, - ) - mixed_audio: MixedAudio = proto.Field( - proto.MESSAGE, - number=13, - oneof='message', - message=MixedAudio, - ) - telephony_transfer_call: TelephonyTransferCall = proto.Field( - proto.MESSAGE, - number=18, - oneof='message', - message=TelephonyTransferCall, - ) - response_type: ResponseType = proto.Field( - proto.ENUM, - number=4, - enum=ResponseType, - ) - channel: str = proto.Field( - proto.STRING, - number=19, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/security_settings.py b/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/security_settings.py deleted file mode 100644 index 05ea6104..00000000 --- a/owl-bot-staging/v3/google/cloud/dialogflowcx_v3/types/security_settings.py +++ /dev/null @@ -1,451 +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 field_mask_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.dialogflow.cx.v3', - manifest={ - 'GetSecuritySettingsRequest', - 'UpdateSecuritySettingsRequest', - 'ListSecuritySettingsRequest', - 'ListSecuritySettingsResponse', - 'CreateSecuritySettingsRequest', - 'DeleteSecuritySettingsRequest', - 'SecuritySettings', - }, -) - - -class GetSecuritySettingsRequest(proto.Message): - r"""The request message for - [SecuritySettingsService.GetSecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettingsService.GetSecuritySettings]. - - Attributes: - name (str): - Required. Resource name of the settings. Format: - ``projects//locations//securitySettings/``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateSecuritySettingsRequest(proto.Message): - r"""The request message for - [SecuritySettingsService.UpdateSecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettingsService.UpdateSecuritySettings]. - - Attributes: - security_settings (google.cloud.dialogflowcx_v3.types.SecuritySettings): - Required. [SecuritySettings] object that contains values for - each of the fields to update. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The mask to control which fields - get updated. If the mask is not present, all - fields will be updated. - """ - - security_settings: 'SecuritySettings' = proto.Field( - proto.MESSAGE, - number=1, - message='SecuritySettings', - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class ListSecuritySettingsRequest(proto.Message): - r"""The request message for [SecuritySettings.ListSecuritySettings][]. - - Attributes: - parent (str): - Required. The location to list all security settings for. - Format: ``projects//locations/``. - page_size (int): - The maximum number of items to return in a - single page. By default 20 and at most 100. - page_token (str): - The next_page_token value returned from a previous list - request. - """ - - 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 ListSecuritySettingsResponse(proto.Message): - r"""The response message for [SecuritySettings.ListSecuritySettings][]. - - Attributes: - security_settings (MutableSequence[google.cloud.dialogflowcx_v3.types.SecuritySettings]): - The list of security settings. - next_page_token (str): - Token to retrieve the next page of results, - or empty if there are no more results in the - list. - """ - - @property - def raw_page(self): - return self - - security_settings: MutableSequence['SecuritySettings'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='SecuritySettings', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class CreateSecuritySettingsRequest(proto.Message): - r"""The request message for [SecuritySettings.CreateSecuritySettings][]. - - Attributes: - parent (str): - Required. The location to create an - [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings] - for. Format: - ``projects//locations/``. - security_settings (google.cloud.dialogflowcx_v3.types.SecuritySettings): - Required. The security settings to create. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - security_settings: 'SecuritySettings' = proto.Field( - proto.MESSAGE, - number=2, - message='SecuritySettings', - ) - - -class DeleteSecuritySettingsRequest(proto.Message): - r"""The request message for [SecuritySettings.DeleteSecuritySettings][]. - - Attributes: - name (str): - Required. The name of the - [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings] - to delete. Format: - ``projects//locations//securitySettings/``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class SecuritySettings(proto.Message): - r"""Represents the settings related to security issues, such as - data redaction and data retention. It may take hours for updates - on the settings to propagate to all the related components and - take effect. - - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - name (str): - Resource name of the settings. Required for the - [SecuritySettingsService.UpdateSecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettingsService.UpdateSecuritySettings] - method. - [SecuritySettingsService.CreateSecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettingsService.CreateSecuritySettings] - populates the name automatically. Format: - ``projects//locations//securitySettings/``. - display_name (str): - Required. The human-readable name of the - security settings, unique within the location. - redaction_strategy (google.cloud.dialogflowcx_v3.types.SecuritySettings.RedactionStrategy): - Strategy that defines how we do redaction. - redaction_scope (google.cloud.dialogflowcx_v3.types.SecuritySettings.RedactionScope): - Defines the data for which Dialogflow applies - redaction. Dialogflow does not redact data that - it does not have access to – for example, Cloud - logging. - inspect_template (str): - `DLP `__ inspect template - name. Use this template to define inspect base settings. - - The ``DLP Inspect Templates Reader`` role is needed on the - Dialogflow service identity service account (has the form - ``service-PROJECT_NUMBER@gcp-sa-dialogflow.iam.gserviceaccount.com``) - for your agent's project. - - If empty, we use the default DLP inspect config. - - The template name will have one of the following formats: - ``projects//locations//inspectTemplates/